
Terminal - Commands using tail - 208 results
ps -eo user,pcpu,pmem | tail -n +2 | awk '{num[$1]++; cpu[$1] += $2; mem[$1] += $3} END{printf("NPROC\tUSER\tCPU\tMEM\n"); for (user in cpu) printf("%d\t%s\t%.2f\t%.2f\n",num[user], user, cpu[user], mem[user]) }'
This is sample output - yours may be different.
The original version gives an error, here is the correct output
tail -F file | egrep --color 'pattern|$'
This is sample output - yours may be different.
tail -f file | egrep --color=always $\|PATTERN
This is sample output - yours may be different.
seq 1111 1122|egrep --color=always $\|12
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
but you can't see the colors in that sample output :(
tail -f FILE | grep --color=always KEYWORD
This is sample output - yours may be different.
dpkg --get-selections | cut -f1 | while read pkg; do dpkg -L $pkg | xargs -I'{}' bash -c 'if [ ! -d "{}" ]; then echo "{}"; fi' | tr '\n' '\000' | du -c --files0-from - | tail -1 | sed "s/total/$pkg/"; done
This is sample output - yours may be different.
176 acl
44 acpi
396 acpi-support
32 acpi-support-base
108 acpid
524 adduser
408 akonadi-server
2416 akregator
388 alsa-base
1840 alsa-utils
1860 amor
96 anacron
120 apmd
4512 apt
104 apt-file
376 apt-utils
140 apt-xapian-index
9184 aptitude
112 at
104 avahi-autoipd
252 avahi-daemon
260 base-files
100 base-passwd
du: cannot access `diverted by dash to: /usr/share/man/man1/sh.distrib.1.gz': No such file or directory
du: cannot access `diverted by dash to: /bin/sh.distrib': No such file or directory
Calculates the size on disk for each package installed on the filesystem (or removed but not purged). This is missing the
| sort -rn
which would put the biggest packges on top. That was purposely left out as the command is slightly on the slow side
Also you may need to run this as root as some files can only be checked by du if you can read them ;)
wget -q -O - 'http://wap.weather.gov.hk/' | sed -r 's/<[^>]+>//g;/^UV/q' | tail -n4
This is sample output - yours may be different.
HK Observatory
At 10 AM
29'C,75%
UV Index: 4
"get Hong Kong weather infomation from HK Observatory
From Hong Kong Observatory wap site ;)"
other one showed alot of blank lines for me
find -type f -name "*.avi" -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d:%02d:%02d\n",$t/3600,$t/60%60,$t%60' | tail -n 1
This is sample output - yours may be different.
change the *.avi to whatever you want to match, you can remove it altogether if you want to check all files.
lsof -P -i -n | cut -f 1 -d " "| uniq | tail -n +2
This is sample output - yours may be different.
kopete
ktorrent
firefox-b
show only the name of the apps that are using internet
ls -t | tail +6 | xargs rm
This is sample output - yours may be different.
yes 6 (tail from 6th line)
file /System/Library/Extensions/*.kext/Contents/MacOS/* |grep -i x86_64 |nl | tail -1 | cut -f1 -f3; file /System/Library/Extensions/*.kext/Contents/MacOS/* |grep -i "mach-o object i386" |nl | tail -1 | cut -f1 -f3
This is sample output - yours may be different.
127 Mach-O 64-bit kext bundle x86_64
140 Mach-O object i386
Not as far off as you thought, now is it?
-mac fanboy
find . -name \*.c | xargs wc -l | tail -1 | awk '{print $1}'
This is sample output - yours may be different.
This is really fast :)
time find . -name \*.c | xargs wc -l | tail -1 | awk '{print $1}'
204753
real 0m0.191s
user 0m0.068s
sys 0m0.116s
ls -lct /etc/ | tail -1 | awk '{print $6, $7, $8}'
This is sample output - yours may be different.
Jul 15 11:46
or
Dec 24 2006
shows also time if its the same year or shows year if installed before actual year and also works if /etc is a link (mac os)
file /System/Library/Extensions/*.kext/Contents/MacOS/* |grep -i x86_64 |nl |tail -1 |cut -f1 -f3 && file /System/Library/Extensions/*.kext/Contents/MacOS/* |grep -v x86_64 |nl |tail -1 |cut -f1 -f3
This is sample output - yours may be different.
127 Mach-O 64-bit kext bundle x86_64
314 Mach-O object i386
Next time you see a mac fanboy bragging about 64-bitness of 10.6 give him this so he might sh?
ls -lct /etc | tail -1 | awk '{print $6, $7}'
This is sample output - yours may be different.
$ ls -lct /etc | tail -1 | awk '{print $6, $7}'
2009-08-25 13:25
Show time and date when you installed your OS.
sudo find /var/log/ -mtime -7 -type f | xargs du -ch | tail -n1
This is sample output - yours may be different.
$ sudo find /var/log/ -mtime -7 -type f | xargs du -ch | tail -n1
25M total
or
$ sudo find /var/log/ -mtime -7 -type f | xargs du -ch | grep total
25M total
get diskusage of files (in this case logfiles in /var/log) modified during the last n days:
sudo find /var/log/ -mtime -n -type f | xargs du -ch
n -> last modified n*24 hours ago
Numeric arguments can be specified as
+n for greater than n,
-n for less than n,
n for exactly n.
=> so 7*24 hours (about 7 days) is -7
sudo find /var/log/ -mtime -7 -type f | xargs du -ch | tail -n1
mirror=ftp://somemirror.com/with/alot/versions/but/no/latest/link; latest=$(curl -l $mirror/ 2>/dev/null | grep util | tail -1); wget $mirror/$latest
This is sample output - yours may be different.
for Sun Freeware
mirror=ftp://sunsite.informatik.rwth-aachen.de/pub/mirror/ftp.sunfreeware.com
pkg=perl
curl -l $mirror/intel/10/ 2>/dev/null | grep $pkg
perl-5.8.5-sol10-intel-local.gz
perl-5.8.7-sol10-x86-local.gz
perl-5.8.8-sol10-x86-local.gz
command above would download only perl-5.8.8-sol10-x86-local.gz
to download latest version of "util", maybe insert a sort if they wont be shown in right order.
curl lists all files on mirror, grep your util, tail -1 will gets the one lists on the bottom and get it with wget
find dir/ -type f | xargs tail -fqn0
This is sample output - yours may be different.
The `-q' arg forces tail to not output the name of the current file
mysql -u<user> -p<password> -s -e 'DESCRIBE <table>' <database> | tail -n +1 | awk '{ printf($1",")}' | head -c -1
This is sample output - yours may be different.
nslookup commandlinefu.com|sed 's/[^0-9. ]//g'|tail -n 1|awk -F " " '{print $2}'
This is sample output - yours may be different.
I use this in a script on my openwrt router to check if my DynDNS needs to be updated, saves your account from being banned for blank updates.
ps -o rss -C httpd | tail -n +2 | (sed 's/^/x+=/'; echo x) | bc
This is sample output - yours may be different.
Display the amount of memory used by all the httpd processes. Great in case you are being Slashdoted!
echo -e "HEAD / HTTP/1.1\nHost: slashdot.org\n\n" | nc slashdot.org 80 | head -n5 | tail -1 | cut -f2 -d-
This is sample output - yours may be different.
ls -t1 | head -n1 | xargs tail -f
This is sample output - yours may be different.
head -$(($RANDOM % $(wc -l < file.txt) +1 )) file.txt | tail -1
This is sample output - yours may be different.
This is sample output - yours may be different.
If you use 'tail -f foo.txt' and it becomes temporarily moved/deleted (ie: log rolls over) then tail will not pick up on the new foo.txt and simply waits with no output.
'tail -F' allows you to follow the file by it's name, rather than a descriptor. If foo.txt disappears, tail will wait until the filename appears again and then continues tailing.
ls -drt /var/log/* | tail -n5 | xargs sudo tail -n0 -f
This is sample output - yours may be different.
==> /var/log/cron <==
==> /var/log/messages <==
==> /var/log/lastlog <==
==> /var/log/wtmp <==
==> /var/log/secure <==
==> /var/log/lastlog <==
==> /var/log/wtmp <==
�1pts/4ts/4myusermyhost.example.com�fJ��?
==> /var/log/secure <==
Jul 21 18:36:19 thost sshd[12730]: Accepted password for myuser from 192.168.100.7 port 50066 ssh2
Jul 21 18:36:19 thost sshd[12730]: pam_unix(sshd:session): session opened for user myuser by (uid=0)
This command finds the 5 (-n5) most frequently updated logs in /var/log, and then does a multifile tail follow of those log files.
Alternately, you can do this to follow a specific list of log files:
sudo tail -n0 -f /var/log/{messages,secure,cron,cups/error_log}