
Terminal - Commands using ls - 408 results
ls -lhR | grep -e "total\|:$"
This is sample output - yours may be different.
.:
total 60K
./documents:
total 2.2G
./error:
total 32K
ls -lhR
Lists everithing using -l "long listing format" wich includes the space used by the folder. Displays it in -h "human readable form" (i.e. 2.2G, 32K), and -R recurses subfolders.
grep -e using a regex, show lines containing the word "total" or a ":" at the end of the line (those with the name of the folder) only.
This is sample output - yours may be different.
ls -1 shows one file per line (update: -1 was not really needed)
wc -l counts the lines received from the previous command
ls -l /dev/disk/by-id/ | grep '/sda$' | grep -o 'ata[^ ]*'
This is sample output - yours may be different.
ata-WDC_WD7500AYYS-01RCB4_WD-WCAPT1303421
Substitute for #11720
Can probably be even shorter and easier.
man ls | egrep "^([A-Z]| [A-Z])"
This is sample output - yours may be different.
LS(1)
NAME
SYNOPSIS
DESCRIPTION
Exit status:
AUTHOR
REPORTING BUGS
COPYRIGHT
SEE ALSO
GNU coreutils 7.4
Uses the formatting of a man page to show an outline of its headers and sub-headers.
ls -l /dev/disk/by-id | egrep ata-.*`hdparm -i /dev/sda | grep SerialNo | sed 's/.*SerialNo=//' | tr -d "\n"`.*sda$ | sed -e 's/.*ata-/ata-/' -e 's|[ ].*||' | tr -d "\n"
This is sample output - yours may be different.
This was tested on Ubuntu 12.04 (Precise) LTS Server. It returns the name of the symlink within /dev/disk/by-id for the physical drive you specify. Change /dev/sda to the one you want, and replace ata- with scsi- or the appropriate type for your drive.
I used this to pre-configure grub-pc during a non-interactive install because I had to tell it which disk to install grub on, and physical disks don't have a UUID such as that blkid provides.
This is sample output - yours may be different.
This is sample output - yours may be different.
works nice if you're only interested in files that are completed downloading from a torrent
This is sample output - yours may be different.
for I in $(find . -depth -type d -not -path "*/.svn*" -print) ; do N="$(ls -1A ${I} | wc -l)"; if [[ "${N}" -eq 0 || "${N}" -eq 1 && -n $(ls -1A | grep .svn) ]] ; then svn rm --force "${I}"; fi ; done
This is sample output - yours may be different.
find / -xdev \( -perm -4000 \) -type f -print0 | xargs -0 ls -l
This is sample output - yours may be different.
ls /var/log/sa/sa[0-9]*|xargs -I '{}' sar -u -f {}|awk '/^[0-9]/&&!/^12:00:01|RESTART|CPU/{print "%user: "$4" %system: "$6" %iowait: "$7" %nice: "$5" %idle: "$9}'|sort -nk10|head
This is sample output - yours may be different.
ls /var/log/sa/sa[0-9]*|xargs -I '{}' sar -q -f {}| awk '/Average/'|awk '{runq+=$2;plist+=$3}END{print "average runq-sz:",runq/NR; print "average plist-sz: "plist/NR}'
This is sample output - yours may be different.
This is sample output - yours may be different.
ls /dev/disk* | xargs -n 1 -t sudo zdb -l | grep GPTE_
This is sample output - yours may be different.
sudo zdb -l /dev/disk0
Password:
sudo zdb -l /dev/disk0s1
sudo zdb -l /dev/disk0s2
sudo zdb -l /dev/disk0s3
sudo zdb -l /dev/disk0s4
sudo zdb -l /dev/disk4
sudo zdb -l /dev/disk4s1
sudo zdb -l /dev/disk4s2
path: '/dev/dsk/GPTE_1928482A-7FE4-482D-B692-3EC6B03159BA'
path: '/dev/dsk/GPTE_1928482A-7FE4-482D-B692-3EC6B03159BA'
path: '/dev/dsk/GPTE_1928482A-7FE4-482D-B692-3EC6B03159BA'
path: '/dev/dsk/GPTE_1928482A-7FE4-482D-B692-3EC6B03159BA'
sudo zdb -l /dev/disk5
path: '/dev/dsk/GPTE_1928482A-7FE4-482D-B692-3EC6B03159BA'
path: '/dev/dsk/GPTE_1928482A-7FE4-482D-B692-3EC6B03159BA'
sudo zdb -l /dev/disk5s1
path: '/dev/dsk/GPTE_1928482A-7FE4-482D-B692-3EC6B03159BA'
path: '/dev/dsk/GPTE_1928482A-7FE4-482D-B692-3EC6B03159BA'
sudo zdb -l /dev/disk7
sudo zdb -l /dev/disk7s1
sudo zdb -l /dev/disk7s2
path: '/dev/dsk/GPTE_78301A52-4AFF-4D96-8DE9-E76ABC14909C'
path: '/dev/dsk/GPTE_78301A52-4AFF-4D96-8DE9-E76ABC14909C'
path: '/dev/dsk/GPTE_78301A52-4AFF-4D96-8DE9-E76ABC14909C'
path: '/dev/dsk/GPTE_78301A52-4AFF-4D96-8DE9-E76ABC14909C'
sudo zdb -l /dev/disk8
path: '/dev/dsk/GPTE_78301A52-4AFF-4D96-8DE9-E76ABC14909C'
path: '/dev/dsk/GPTE_78301A52-4AFF-4D96-8DE9-E76ABC14909C'
sudo zdb -l /dev/disk8s1
path: '/dev/dsk/GPTE_78301A52-4AFF-4D96-8DE9-E76ABC14909C'
path: '/dev/dsk/GPTE_78301A52-4AFF-4D96-8DE9-E76ABC14909C'
sudo zdb -l /dev/disk8s1s1
sudo zdb -l /dev/disk8s1s1s1
sudo zdb -l /dev/disk8s1s1s2
sudo zdb -l /dev/disk8s1s2
sudo zdb -l /dev/disk8s1s3
path: '/dev/dsk/GPTE_78301A52-4AFF-4D96-8DE9-E76ABC14909C'
path: '/dev/dsk/GPTE_78301A52-4AFF-4D96-8DE9-E76ABC14909C'
sudo zdb -l /dev/disk8s1s4
sudo zdb -l /dev/disk8s1s4s1
macbookpro08-centrim:~ gjp22$
cd () { command cd $1 && ls ; }
This is sample output - yours may be different.
# cd /etc/redhat-lsb/
lsb_killproc lsb_log_message lsb_pidofproc lsb_start_daemon
Changes dir to $1 and executes ls. As simple as useful
This is sample output - yours may be different.
root@staging:~/jfr/B_logical_offset1337/etc# ls -l | grep "\->"
lrwxrwxrwx. 1 root root 22 M?r 18 2009 grub.conf -> ../boot/grub/grub.conf
lrwxrwxrwx. 1 root root 11 M?r 18 2009 init.d -> rc.d/init.d
lrwxrwxrwx 1 root root 7 M?r 18 2009 rc -> rc.d/rc
lrwxrwxrwx 1 root root 10 M?r 18 2009 rc0.d -> rc.d/rc0.d
lrwxrwxrwx 1 root root 10 M?r 18 2009 rc1.d -> rc.d/rc1.d
lrwxrwxrwx 1 root root 10 M?r 18 2009 rc2.d -> rc.d/rc2.d
Pretty lame to rely on grep and "\->"? Maybe. But it works ;)
ls -l /proc/*/fd/* | grep 'deleted'| grep "\/proc.*\file-name-part"
This is sample output - yours may be different.
to@tolaptop:~$ ls -l /proc/*/fd/* | grep 'deleted'| grep "\/proc.*\.mp3"
lr-x------ 1 totti root 64 2012-09-13 14:24 /proc/3275/fd/27 -> /home/to/Downloads/07. AAA.mp3.part (deleted)
Accidentally deleted some file while used by a program ? (Eg: a song)
Use this command to find the file handle and recover using
cp /proc/pid/fd/filehandle /new/recoverd-file.ext
This is sample output - yours may be different.
ln -s /base/* /target && ls -l /target
This is sample output - yours may be different.
wget --no-use-server-timestamps $(curl $(curl http://wallbase.cc/random/23/eqeq/1920x1080/0/100/20 | grep 'wallpaper/' | awk -F'"' '{print $2}' | head -n1) | grep -A4 bigwall | grep img | awk -F'"' '{print $2}'); feh --bg-center $(ls -1t | head -n1)
This is sample output - yours may be different.
alias ls='if [[ -f .hidden ]]; then while read l; do opts+=(--hide="$l"); done < .hidden; fi; ls --color=auto "${opts[@]}"'
This is sample output - yours may be different.
ant@dev(/ntfs)# \ls -F
$RECYCLE.BIN/ System Volume Information/ Shared/
ant@dev(/ntfs)# cat .hidden
$RECYCLE.BIN
System Volume Information
ant@dev(/ntfs)# ls -F
Shared/
Sometimes I would like to see hidden files, prefix with a period, but some files or folders I never want to see (and really wish I could just remove all together).
ls | grep -Ze ".*rar" | xargs -d '\n' -I {} mv {} backup-folder
This is sample output - yours may be different.
In the example suppose we want to move all *.rar files in the current folder to a backupfolder
ls -il; find * \( -type d -prune \) -o -inum <NUM> -exec rm -i {} \;
This is sample output - yours may be different.
$ ls
?????D?P?test.txt
$ rm ./
^_?^H^H?D^\P^Ctest.txt
$ ls -b
\037\213\b\b\240D\034P\003test.txt
$ rm \037*
rm: cannot remove `037*': No such file or directory
$ ls -il
total 8
86870 -rw-r--r-- 1 mememe mememe 0 2012-08-03 14:38 ?????D?P?test.txt
$ find * \( -type d -prune \) -o -inum 86870 -exec rm -i {} \;
rm: remove regular empty file `\037\213\b\b\240D\034P\003test.txt'? y
find . -type f -exec ls -l --full-time {} + | sort -k 6,7
This is sample output - yours may be different.
This sorts files in multiple directories by their modification date. Note that sorting is done at the end using "sort", instead of using the "-ltr" options to "ls". This ensures correct results when sorting a large number of files, in which case "find" will call "ls" multiple times.
find . -type f -exec ls -shS {} + | head -10
This is sample output - yours may be different.
1.2G ./This -is -a "bad" filename with dashes, spaces, and unmatched 'quotes! -asdf " < > ? *
168M ./ok_go_-_twelve_remixes_of_four_songs-mp3-1343176765.zip
156M ./mc_frontalot_-_favoritism-mp3-1343247538.zip
119M ./hitoshi_sakimoto_-_best_of_the_valkyria_chronicles-mp3-1343176765.zip
108M ./Tin/christopher_tin_-_calling_all_dawns-mp3-1343176765.zip
89M ./TMBG/they_might_be_giants_-_album_raises_new_and_troubling_questions-mp3-1343248905.zip
85M ./jonathan_coulton_-_jonathan_coultons_greatest_hit_plus_13_other_songs-mp3-1343245716.zip
8.2M ./TMBG/They Might Be Giants/Album Raises New and Troubling Questions/13 Tubthumping (feat. the Onion AV Club Choir).mp3
7.6M ./TMBG/They Might Be Giants/Album Raises New and Troubling Questions/19 Dirt Bike (with the Other Thing Brass Band).mp3
7.5M ./TMBG/They Might Be Giants/Album Raises New and Troubling Questions/03 You Probably Get That A Lot (Elegant Too Remix).mp3
This requires a version of GNU find that supports the -exec {} + action, but it seems more straightforward than the versions already posted.