
Terminal - Commands using grep - 1,674 results
grep -Eoa "\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b" Filetosearch.txt
This is sample output - yours may be different.
Command returns valid IP addresses. Append the following regex to additionally filter out NAT and reserved IP addresses
| grep -Ev "^0|\.0[0-9]|^10\.|^127\.|^169\.|^172\.(1[6-9]|2[0-9]|3[01])|^192.168.|^2(2[4-9]|3[0-9])|^2(4[0-9]|5[0-5])"
cat File.txt | grep -io 'http://www.acme.com/a/files/.*.pdf'| uniq
This is sample output - yours may be different.
lsof -ns | grep REG | grep deleted | awk '{s+=$7/1024} END {print s}'
This is sample output - yours may be different.
cat /etc/named.conf | grep -Po '(?<=(named/)).*(?=\.db)'
This is sample output - yours may be different.
Allows you to have a list of the domains on the server.
find . -name '*.jar' | xargs -l jar vtf | grep XXX.java
This is sample output - yours may be different.
smartctl -a /dev/sda |grep Writ |awk '{print $NF/2/1024/1024/1024 " TeraBytes Written"}'
This is sample output - yours may be different.
smartctl -a /dev/sdc |grep Writ |awk '{print $NF/2/1024/1024/1024 " TeraBytes Written"}'
112.314 TeraBytes Written
You must have smartmontools installed for this to work. This also assumes you 512 byte sector sizes, this is pretty standard.
ls | tr '[[:punct:][:space:]]' '\n' | grep -v "^\s*$" | sort | uniq -c | sort -bn
This is sample output - yours may be different.
I'm sure there's a more elegant sed version for the tr + grep section.
gcloud components list | grep "^| Not" | sed "s/|\(.*\)|\(.*\)|\(.*\)|/\2/" | xargs echo gcloud components update
This is sample output - yours may be different.
gcloud components update pkg-go pkg-java pkg-python app gae-python-launcher-mac gae-go gae-java gae-python
Google Cloud SDK comes with a package manager `gcloud components` but it needs a bit of `sed` to work. Modify the "^| Not" bit to change the package selection. (The gcloud --format option is currently broken)
psql -U quassel quassel -c "SELECT message FROM backlog ORDER BY time DESC LIMIT 1000;" | grep my-query
This is sample output - yours may be different.
alias quassel-grep='psql -U quassel quassel -c "SELECT message FROM backlog ORDER BY time DESC LIMIT 1000;" | grep'
# Get messages directed at me
quassel-grep -E Tatsh[,\:]
Replace the credentials to psql if necessary, and the my-query part with your query.
curl -s http://pages.cs.wisc.edu/~ballard/bofh/bofhserver.pl |grep 'is:' |awk 'BEGIN { FS=">"; } { print $10; }'
This is sample output - yours may be different.
Rhythmic variations in the voltage reaching the power supply.
Sure, it's dirty, but it's quick, it only displays the excuse, and it works.
url=`curl http://proxybay.info/ | awk -F'href="|" |">|</' '{for(i=2;i<=NF;i=i+4) print $i,$(i+2)}' | grep follow|sed 's/^.\{19\}//'|shuf -n 1` && firefox $url
This is sample output - yours may be different.
polls the pirate bay mirrors list and chooses a random site and opens it for you in firefox
git reflog --date=local | grep "Oct 2 .* checkout: moving from .* to" | grep -o "[a-zA-Z0-9\-]*$" | sort | uniq
This is sample output - yours may be different.
my_new_feature
my_second_new_feature
master
Replace "Oct 2" in the first grep pattern to be the date to view branch work from
echo "DISK:";df -Pl | grep -v "Filesystem" | awk '{print $5,$6}' ; echo "MEM:" ; free -mto | awk '{ print $1,$2,$3,$4 }'; echo "CPU:"; top -b -d1 -n1 | grep Cpu | awk '{print $2,$3,$4,$5,$6,$7,$8,$9}';echo "LOAD:"; cat /proc/loadavg
This is sample output - yours may be different.
DISK:
94% /
6% /boot
0% /dev/shm
MEM:
total used free shared
Mem: 7983 7580 403
Swap: 12287 6 12281
Total: 20271 7586 12685
CPU:
0.3%us, 0.2%sy, 0.1%ni, 98.2%id, 1.1%wa, 0.0%hi, 0.1%si, 0.0%st
LOAD:
0.02 0.03 0.00 1/417 15018
Monitoring system in one line :
DISK : disk space
MEM: memory ( mem , swap, Total)
CPU : all information about cpu activity
LOAD : load average
for line in `docker ps | awk '{print $1}' | grep -v CONTAINER`; do docker ps | grep $line | awk '{printf $NF" "}' && echo $(( `cat /sys/fs/cgroup/memory/docker/$line*/memory.usage_in_bytes` / 1024 / 1024 ))MB ; done
This is sample output - yours may be different.
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=merged.pdf -dBATCH `ls | grep foo`
This is sample output - yours may be different.
docker images | grep '' | awk '{print $3}' | xargs docker rmi
This is sample output - yours may be different.
docker ps -a | grep 'Exit' | awk '{print $1}' | xargs docker rm
This is sample output - yours may be different.
ps -efL | grep <Process Name>
This is sample output - yours may be different.
for I in *.CR2; do if [ `exiv2 pr -p a -u $I | grep 'xmp.Rating' | awk '{ print $4 }'` == "1" ]; then echo $I; fi; done
This is sample output - yours may be different.
( eval $(grep -z '^DBUS_SESSION_BUS_ADDRESS' /proc/$(pgrep -u $USER plasma-overlay)/environ); export DBUS_SESSION_BUS_ADDRESS; kquitapp plasma-overlay )
This is sample output - yours may be different.
So this first obtains address of the DBUS session, as it's not available by default over SSH. Then it tells plasma-overlay to exit. `kquitapp` is pretty much an equivalent of the qdbus calls.
netstat -anp | grep ":<port>"
This is sample output - yours may be different.
cat /var/log/syslog | grep score= | awk '{print $15}' | more
This is sample output - yours may be different.
tail -1f /var/opt/fds/logs/TraceEventLogFile.txt.0 | grep <msisdn> | tee <test-case-id>.trace | tr '|' '\n'
This is sample output - yours may be different.
1408564155.352000[20140820 15:49:15.352000] Module: PSC-SubscriberHandler/8.2/A/1 Event: OperationManager: Trace of output message, ResultData and ChargingState ID: 5000101 Type: 2269699863188406273 Count: 12076 Aff.Obj: 590690271653 Info:
<result>
<header>
<subscriberId>
<type>AST_MSISDN_INTERNATIONAL</type>
<data>590690271653</data>
</subscriberId>
</header>
<data>
<result>
<code>OK</code>
<optionalActionResult disc="OP_GET">
<master>
<type>AST_MSISDN_SUBSCRIBER</type>
<data>590690271653</data>
</master>
<masterSubordinateFlag>false</masterSubordinateFlag>
<currency>true</currency>
<language>1</language>
<serviceClass>5700</serviceClass>
<originalServiceClass/>
<temporaryBlockedFlag>false</temporaryBlockedFlag>
.
.
.
This command allows to follow up a trace on SDP (CS5.2), at the same time as the trace records are stored in the file with "raw" format.
Trace files in native format are useful to filter the records before to translation from '|' to '\n'.
Example:
grep -v OP_GET <raw-records>.trace | tr '|' '\n'
grep Failed auth.log | rev | cut -d\ -f4 | rev | sort -u
This is sample output - yours may be different.
192.168.1.1
192.168.2.2
10.0.0.1
Find the failed lines, reverse the output because I only see 3 indicators after the IP address, i.e. port, port#, ssh2 (in my file), cut to the 4th field (yes, you could awk '{print $4}'), reverse the output back to normal and then sort -u (for uniq, or sort | uniq).
This is sample output - yours may be different.
Emily:ivan Ivan$ ls -lah | grep ^l.
lrwxr-xr-x 1 Ivan staff 29B Jul 14 02:04 .agignore -> /Users/ivan/dotfiles/agignore
lrwxr-xr-x 1 Ivan staff 28B Jul 14 02:04 .aliases -> /Users/ivan/dotfiles/aliases
lrwxr-xr-x 1 Ivan staff 26B Jul 14 02:04 .gemrc -> /Users/ivan/dotfiles/gemrc
lrwxr-xr-x 1 Ivan staff 30B Jul 14 02:04 .gitconfig -> /Users/ivan/dotfiles/gitconfig
Tested with GNU and BSD ls.