/home/bill/System_maintenance/Linux/ls notes.txt with full path $ ls "/media/bill/PROJECTS/Conference guides/Author guide website/"*.* with line numbers $ ls "/media/bill/PROJECTS/Conference guides/Author guide website/"*.* BETTER to use find - more powerful : $ find "/media/bill/PROJECTS/Qnial/MY_NDFS/" -maxdepth 1 -type f -name "*" | tr \\n \\0 | xargs -0 -IFILE grep --with-filename --line-number "sym_stdForm_file" "FILE" | grep "IS OP" #] pth_get_byteSize() - see "$d_bin"'fileops.sh' for example # $ ls -l "$d_symArg"'arrays/raw/ary_idx_get_itm usage.txt' # -rw-r--r-- 1 bill bill 194 Jul 12 20:16 /media/bill/Dell2/Website - raw/Qnial/MY_NDFS/QNial [symbol, arg] changes/arrays/raw/ary_idx_get_itm usage.txt #https://pythonbaba.com/ls-l-command-with-output/ #] ls -l command with output #] After executing the ls -l command, we can see the below output. The ls -l shows the total number of files in the current directory, it shows the file’s attributes and permissions in 7 column format. Let’s understand the meaning of the seven columns along with the description. #] The first column of ls -l shows permission of the file. #] Second column of ls -l represent the total number of links. #] The third column of ls -l tells the name of the file owner. #] The fourth column of ls -l represents the name of Group ownership. #] The fifth column of ls -l shows the total size of the File in bytes. #] The sixth column of ls -l shows the last modification time of the file. #] Seventh column of ls -l represent the name of the file. # check for bytes for large files : # $ ls -l "$d_webRawe"'Bill Howells videos/120214 Venus et Mars, au dela d une histoire d amour/Mythology.ogv' | sed 's|^\([rwx-]*\) \([0-9]*\) \([a-zA-Z]*\) \([a-zA-Z]*\) \([0-9]*\) \([a-zA-Z]*\) \(.*\) \(.*\) \/\(.*\)|\5|' # $ ls -l "$d_symArg"'arrays/raw/ary_idx_get_itm usage.txt' | sed 's|^\([rwx-]*\) \([0-9]*\) \([a-zA-Z]*\) \([a-zA-Z]*\) \([0-9]*\) \([a-zA-Z]*\) \(.*\) \(.*\) \/\(.*\)|\5|' 08********08 11Nov2021 list directories only $ ls -1 --directory '/media/bill/Dell2/Website - raw/Qnial/MY_NDFS/' | sed "s|""$d_Qndfs""||" qnial> FOR sub WITH ('Bessel' '' 'Mindcode/' first host_result link 'find "$d_Qndfs""MindCode/" -name "*.ndf" | grep --invert-match "z_Old\|z_Archive" ' qnial> FOR sub WITH ('Bessel' '' 'Mindcode/' first host_result link 'find "$d_Qndfs""MindCode/" -name "*.ndf" | grep --invert-match "z_Old\|z_Archive" ' $ find "$d_Qndfs" -name "*.ndf" | grep --invert-match "z_Old\|z_Archive" $ find "$d_Qndfs"'MindCode/' -name "*.ndf" | grep --invert-match "z_Old\|z_Archive" $ find -type d -name "$d_Qndfs" | grep --invert-match "z_Old\|z_Archive" $ ls -1 --directory '/media/bill/Dell2/Website - raw/Qnial/MY_NDFS' | sed "s|""$d_Qndfs""||" >> why doesn't this work? $ ls -1 --directory '/media/bill/Dell2/Website - raw/Qnial/MY_NDFS/' | sed "s|""$d_Qndfs""||" +-----+ https://linuxhandbook.com/list-only-directories/ Like anything in Linux, there are several ways to accomplish the same task. Listing only the directories is no different: ls -d */ ls -l | grep '^d' find . -maxdepth 1 -type d echo */ tree -d -L 1 Try : $ ls -1 '/media/bill/Dell2/Website - raw/Qnial/MY_NDFS/' | grep '^d' >> no good $ ls '/media/bill/Dell2/Website - raw/Qnial/MY_NDFS/' | grep '^d' >> this includes files $ ls '/media/bill/Dell2/Website - raw/Qnial/MY_NDFS/' | grep '^d' $ ls -l '/media/bill/Dell2/Website - raw/Qnial/MY_NDFS/' | grep '^d' $ ls -l '/media/bill/Dell2/Website - raw/Qnial/MY_NDFS/' | grep '^d' drwxr-xr-x 2 bill bill 4096 May 3 2021 Bessel drwxr-xr-x 2 bill bill 4096 May 3 2021 Bessell - Runge-Kutta drwxr-xr-x 5 bill bill 4096 May 3 2021 Cheng - semi-tensor and switching control, Matlab toolbox drwxr-xr-x 9 bill bill 4096 Jun 3 17:14 Climate and Sun drwxr-xr-x 3 bill bill 4096 Jun 29 16:05 dictionaries drwxr-xr-x 3 bill bill 4096 Sep 29 16:42 economics, markets drwxr-xr-x 2 bill bill 4096 Sep 29 15:57 email drwxr-xr-x 2 bill bill 4096 May 3 2021 email fix Thunderbird drwxr-xr-x 2 bill bill 4096 Sep 10 16:13 email - mass response processing drwxr-xr-x 2 bill bill 4096 May 3 2021 Examples drwxr-xr-x 2 bill bill 4096 Jun 8 10:12 iconv - Unicode to ASCII drwxr-xr-x 3 bill bill 4096 Sep 29 14:53 IJCNN 2013 Dallas TX drwxr-xr-x 8 bill bill 4096 Aug 30 15:32 MindCode drwxr-xr-x 2 bill bill 4096 May 3 2021 Ord Diff Eq Integration drwxr-xr-x 2 bill bill 4096 Sep 29 16:04 symbols drwxr-xr-x 2 bill bill 4096 Jun 8 10:12 uni2ascii drwxr-xr-x 2 bill bill 4096 May 3 2021 USB_backup drwxr-xr-x 8 bill bill 4096 Oct 5 19:41 video production drwxr-xr-x 3 bill bill 4096 Sep 29 16:45 webSite drwxr-xr-x 2 bill bill 61440 Nov 6 15:54 z_Archive drwxr-xr-x 2 bill bill 126976 Nov 3 12:06 z_Old >> L not 1 $ ls -l '/media/bill/Dell2/Website - raw/Qnial/MY_NDFS/' | grep '^d' | cut --bytes=-62 >> nyet +-----+ https://stackoverflow.com/questions/14352290/listing-only-directories-using-ls-in-bash For all folders without subfolders: find /home/alice/Documents -maxdepth 1 -type d For all folders with subfolders: find /home/alice/Documents -type d edited Jan 24 at 15:04 Peter Mortensen 29k2121 gold badges9797 silver badges124124 bronze badges answered Jul 23 '14 at 8:30 at3m +--+ $ find "$d_Qndfs" -maxdepth 1 -type d | sed "s|""$d_Qndfs""||" video production z_Old IJCNN 2013 Dallas TX dictionaries MindCode email fix Thunderbird uni2ascii iconv - Unicode to ASCII economics, markets webSite Cheng - semi-tensor and switching control, Matlab toolbox email - mass response processing z_Archive Ord Diff Eq Integration email Bessel USB_backup Examples Bessell - Runge-Kutta Climate and Sun symbols +--+ >> bingo Once again, ls isn't the right tool 08********08 28Sep2021 list hidden [file, dir]s only $ ls -1a ~ | grep "." >> lists others as well $ ls -1a ~ | grep "^." >> same problem $ ls -1a ~ | grep "^\." >> OK ************* 22Mar2019 seearch "linux ls and how do I output the full filepath?" https://stackoverflow.com/questions/246215/how-can-i-generate-a-list-of-files-with-their-absolute-path-in-linux#246220 Use this for dirs (the / after ** is needed in bash to limit it to directories): ls -d -1 "$PWD/"**/ this for files and directories directly under the current directory, whose names contain a .: ls -d -1 "$PWD/"*.* this for everything: ls -d -1 "$PWD/"**/* Taken from here http://www.zsh.org/mla/users/2002/msg00033.html In bash, ** is recursive if you enable shopt -s globstar. edited Feb 10 at 9:01, Peter Cordes answered Aug 26 '10 at 6:42, user431529 *********** 11Aug2017 11:46 list files sorted by size My first approach : $ du >"/home/bill/System_maintenance/170811 du log no mwad0hk.txt" --exclude=mwad0hks.default >> but numbers are left-adjusted - not so good for sort https://www.cyberciti.biz/faq/linux-ls-command-sort-by-file-size/ $ ls --sort=size -l >> I used recursive version from /home/bill : $ ls --sort=size -lR >> but this separates by directory Now try (non-recursive test first) : $ ls -l | sed >"/home/bill/System_maintenance/170811 ls -lR sed.txt" 's/^[.]\{23\}//' >> didn't cut first 23 characters .. $ ls -l | sed >"/home/bill/System_maintenance/170811 ls -lR sed.txt" 's/^.\{23\}//' >> YES!! Now try recursive with sort $ ls -lR | sed 's/^.\{23\}//' | sort >"/home/bill/System_maintenance/170811 ls -lR sed.txt" >> sort ignores spaces! can this be changed? >> try --numeric-sort, non-recursive, stdout to screen $ ls -l | sed 's/^.\{23\}//' | sort >> weird from man sort : +-----+ -g, --general-numeric-sort compare according to general numerical value -i, --ignore-nonprinting consider only printable characters -M, --month-sort compare (unknown) < 'JAN' < ... < 'DEC' -h, --human-numeric-sort compare human readable numbers (e.g., 2K 1G) -n, --numeric-sort compare according to string numerical value +-----+ >> try -g , non-recursive, stdout to screen $ ls -l | sed 's/^.\{23\}//' | sort -g >> YES!! that worked $ ls -lR | sed 's/^.\{23\}//' | sort -g >"/home/bill/System_maintenance/170811 ls -lR sed.txt" Now - remove leading spaces, non-recursive, stdout to screen $ ls -l | sed 's/^.\{23\}//' | sed 's/^[ ]*//' | sort -g >> That eliminates spaces, now for blank lines, need recursive to show : $ ls -l | sed 's/^.\{23\}//' | sed 's/^[ ]*//' | sed 's/^$//' | sort -g >> didn't work >> referring to example in http://www.grymoire.com/Unix/Sed.html#uh-8 $ ls -lR | grep --invert-match '^$' | sed 's/^.\{23\}//' | sed 's/^[ ]*//' | sort >"/home/bill/System_maintenance/170811 ls -lR sed.txt" -g >> still have [.:A-Za-z] (maybe from lines too long?) $ ls -lR | grep --invert-match '^$' | sed 's/^.\{23\}//' | sed 's/^[ ]*//' | sed 's/^[.:/A-Za-z]*//' | sort >"/home/bill/System_maintenance/170811 ls -lR sed.txt" -g >> now blank lines and spaces have come back!!?? $ ls -lR | grep --invert-match '^$' | sed 's/^.\{23\}//' | sed 's/^[ ]*//' | sed 's/^[.,:\/_A-Za-z]*//' | sort >"/home/bill/System_maintenance/170811 ls -lR sed.txt" -g Saved as bash script : /media/bill/HOWELL_BASE/bin/files sorted by size, recursive.sh *********** 05May2017 11:06 filepath included - use find !! *********** 01May2017 ls - DON'T use with regexpr !! 22Mar2019 - NYET! put wildcards outside of quotes!!! $ ls -1 "/usr/lib/x86_64-linux-gnu/dune"?* >> doesn't work $ ls -1 "/usr/lib/x86_64-linux-gnu" | grep "dune" >> OK, we're good! *********** To list files since a date : use find!! see "/home/bill/System_maintenance/Linux/find notes.txt" # enddoc