
Terminal - Commands using grep - 1,375 results
systemd-analyze plot | curl -sF file1=@- http://ompldr.org/upload | grep -P -o "(?<=File:).*(http://ompldr.org/.*)\<\/a\>" | sed -r 's@.*(http://ompldr.org/\w{1,7}).*@\1@'
This is sample output - yours may be different.
http://ompldr.org/vZ2dyOA
Useful for figuring out which services are lagging the boot time on the system.
grep -l <string-to-match> * | xargs grep -c <string-not-to-match> | grep '\:0'
This is sample output - yours may be different.
This is sample output - yours may be different.
find . \( -name \*.cgi -o -name \*.txt -o -name \*.htm -o -name \*.html -o -name \*.shtml \) -print | xargs grep -s pattern
This is sample output - yours may be different.
find . -type f -exec grep -ils stringtofind {} +
This is sample output - yours may be different.
find . -name "*" -print | xargs grep -s pattern
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.
cd ~/.msf4/loot && cat *mscache* | cut -d '"' -f 2,4 | sed s/\"/\:/g | tr -cd '\11\12\40-\176' | grep -v Username | cut -d : -f 1,2 | awk -F':' '{print $2,$1}' | sed 's/ /:/g' > final.dcc.hash
This is sample output - yours may be different.
wget -q -O - www.myip.cn | grep -Po "(\d+\.){3}\d+" -m 0
This is sample output - yours may be different.
pacman -Qi | grep 'Name\|Size\|Description' | cut -d: -f2 | paste - - - | awk -F'\t' '{ print $2, "\t", $1, "\t", $3 }' | sort -rn
This is sample output - yours may be different.
253888.00 KiB wine A compatibility layer for running Windows programs
241743.00 KiB libreoffice-common common files for LibreOffice - a productivity suite that is compatible with other major office suites
121212.00 KiB openjdk6 Free Java environment based on OpenJDK 6.0 with IcedTea6 replacing binary plugs.
108232.00 KiB chromium The open-source project behind Google Chrome, an attempt at creating a safer, faster, and more stable browser
This, like the other commands listed here, displays installed arch packages. Unlike the other ones this also displays the short description so you can see what that package does without having to go to google. It also shows the largest packages on top. You can optionally pipe this through head to display an arbitrary number of the largest packages installed (e.g. ... | head -30 # for the largest 30 packages installed)
grep -nH "text" -r . --include *name.xml
This is sample output - yours may be different.
/dir/deploy/first-name.xml:20: <value>text1</value>
/dir2/deploy/last-name.xml:11: <value>text2</value>
Alternative using find and grep
find . -type f -name *ds.xml -exec grep -n user-name /dev/null {} \;
Using CAT and grep
cat `find . -name '*ds.xml' -print`|grep 'looking for'
vim `git status | grep modified | awk '{print $3}'`
This is sample output - yours may be different.
This oneliner gets all the 'modified' files in your git repository, and opens all of them in vim.
Very handy when you're starting to work in the morning and you simply want to review your modified files before committing them.
Maybe there are better ways to do that (and maybe integrated in vim and/or git, who knows), but I found quicker to do this oneliner.
nmap -sP 192.168.1.0/24 | grep "Nmap scan report for"| cut -d' ' -f 5 > ips.txt
This is sample output - yours may be different.
find /path/to/search/directory -exec grep -Hn "pattern" {} \;
This is sample output - yours may be different.
for host in $HOSTNAMES; do ping -q -c3 $host && ssh $host 'command' & for count in {1..15}; do sleep 1; jobs | wc -l | grep -q ^0\$ && continue; done; kill %1; done &>/dev/null
This is sample output - yours may be different.
Cleaned up and silent with &>/dev/null at the end.
find . -type f -exec grep -l "some string" {} \;
This is sample output - yours may be different.
for host in $MYHOSTS; do ping -q -c3 $H 2>&1 1>/dev/null && ssh -o 'AllowedAuthe ntications publickey' $host 'command1; command2' & for count in 1 2 3 4 5; do sleep 1; jobs | wc -l | grep -q ^0\$ && continue; done; kill %1; done
This is sample output - yours may be different.
Execute commands serially on a list of hosts. Each ssh connection is made in the background so that if, after five seconds, it hasn't closed, it will be killed and the script will go on to the next system.
Maybe there's an easier way to set a timeout in the ssh options...
scrot -d 3 '/tmp/%Y-%m-%d_$wx$h.png' -e 'cat $f'|curl -F "image=@-" -F "key=1913b4ac473c692372d108209958fd15" http://api.imgur.com/2/upload.xml|grep -Eo "<original>(.)*</original>" | grep -Eo "http://i.imgur.com/[^<]*"
This is sample output - yours may be different.
scrot -d 3 '/tmp/%Y-%m-%d_$wx$h.png' -e 'cat $f'|curl -F "image=@-" -F "key=1913b4ac473c692372d108209958fd15" http://api.imgur.com/2/upload.xml|grep -Eo "<original>(.)*</original>" | grep -Eo "http://i.imgur.com/[^<]*"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 138k 0 640 100 137k 72 16080 0:00:08 0:00:08 --:--:-- 17506
http://i.imgur.com/YBzHR.pn
That its my personal key that i dont use, if you want yours, go to imgur and get it, or use that one
for file in `ls -t \`find . -name "*.zip" -type f\``; do found=`unzip -c "$file" | grep --color=always "PATTERN"`; if [[ $found ]]; then echo -e "${file}\n${found}\n"; fi done
This is sample output - yours may be different.
for file in `ls -t \`find . -name "*.zip" -type f\``; do
found=`unzip -c "$file" | grep --color=always "PATTERN"`;
if [[ $found ]]; then echo -e "${file}\n${found}\n"; fi
done
vim $(grep [REGULAR_EXPRESSION] -R * | cut -d":" -f1 | uniq)
This is sample output - yours may be different.
grep -rl string_to_find public_html/css/ | xargs -I '{}' vim +/string_to_find {} -c ":s/string_to_find/string_replaced"
This is sample output - yours may be different.
Open all files which have some string go directly to the first line where that string is and run command on it.
Other examples:
Run vim only once with multiple files (and just go to string in the first one):
grep -rl string_to_find public_html/css/ | xargs vim +/string_to_find
Run vim for each file, go to string in every one and run command (to delete line):
grep -rl string_to_find public_html/css/ | xargs -I '{}' vim +/string_to_find {} -c ":delete"
cat file.txt | grep -v /$ > newfile.txt
This is sample output - yours may be different.
for i in $(ps -eo pid|grep -v PID);do echo ""; echo -n "==$i== ";awk '/^read|^write/{ORS=" "; print}' /proc/$i/io 2>/dev/null; echo -n " ==$i=="; done|sort -nrk5|awk '{printf "%s\n%s %s\n%s %s\n%s\n\n",$1,$2,$3,$4,$5,$6}'
This is sample output - yours may be different.
for i in `ls /var/log/sa/|grep -E "sa[0-9][0-9]"`;do echo -ne "$i -- ";sar -r -f /var/log/sa/$i|awk '{ printf "%3.2f\n",($4-$6-$7)*100/(3+$4)}'|grep -Eiv "average|linux|^ --|0.00|^-" |awk '{sum+=$1 }END{printf "Average = %3.2f%%\n",sum/NR}';done
This is sample output - yours may be different.
# for i in `ls /var/log/sa/|grep -E "sa[0-9][0-9]"`;do echo -ne "$i -- ";sar -r -f /var/log/sa/$i|awk '{ printf "%3.2f\n",($4-$6-$7)*100/(3+$4)}'|grep -Eiv "average|linux|^ --|0.00|^-" |awk '{sum+=$1 }END{printf "Average = %3.2f%%\n",sum/NR}';done
sa01 -- Average = 91.10%
sa02 -- Average = 95.02%
sa03 -- Average = 83.10%
sa04 -- Average = 78.05%
sa05 -- Average = 77.79%
sa06 -- Average = 77.70%
sa07 -- Average = 77.58%
sa08 -- Average = 77.60%
sa09 -- Average = 77.64%
sa10 -- Average = 80.94%
sa11 -- Average = 84.72%
p=1 ; lynx -source http://www.lipsum.com/feed/xml?amount=${p} | grep '<lipsum>' -A$(((p-1))) | perl -p -i -e 's/\n/\n\n/g' | sed -n '/<lipsum>/,/<\/lipsum>/p' | sed -e 's/<[^>]*>//g'
This is sample output - yours may be different.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce consequat tincidunt diam ut lobortis. Aenean sed dolor nibh, eget consequat purus. Curabitur luctus nibh nec velit dignissim ultrices. Mauris id elit ac diam tempus facilisis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Proin euismod consectetur lorem, sit amet pellentesque felis elementum a. Vivamus congue nulla et lorem convallis rutrum. Curabitur dapibus aliquam nunc sed vestibulum. In at ornare mauris. Integer congue sem turpis. In at velit at neque facilisis facilisis a egestas justo. Proin gravida diam sed metus elementum egestas. Maecenas et enim vel dolor dictum faucibus. Sed ultrices rutrum nisi, vitae rutrum tortor consequat ac. Maecenas at nunc in neque vestibulum varius.
This fixes the extra lines you get when you request only 1 paragraph using a little bit of grep. Just set p to the number of paragraphs you want.