
Terminal - Commands using echo - 1,101 results
mkalias () { echo "alias $1=\"$2\"" >> ~\.bash_aliases }
This is sample output - yours may be different.
Is used like this:
mkalias rmcache "rm -rfv app/cache/*"
find . | while read line; do test `stat -c %u $line` -eq 1003 && chown android:android $line && echo $line; done
This is sample output - yours may be different.
if date -d 2006-10-10 >> /dev/null 2>&1; then echo 1; else echo 0; fi
This is sample output - yours may be different.
# if date -d 2006-10-10 >> /dev/null 2>&1; then echo 1; else echo 0; fi
1
# if date -d 2006-40-10 >> /dev/null 2>&1; then echo 1; else echo 0; fi
0
# if date -d 2006-13-10 >> /dev/null 2>&1; then echo 1; else echo 0; fi
0
# if date -d 2006-11-31 >> /dev/null 2>&1; then echo 1; else echo 0; fi
0
On CentOS at least, date returns a boolean for the common date string formats, including YYYY-MM-DD. In the sample output, you can see various invalid dates returning 0 whereas a simple regex check would return 1 for the invalid dates.
-d, --date=STRING display time described by STRING, not `now'
The version of date on OS X does not appear to have this same option.
echo "main(i){for(i=0;;i++)putchar(((i*(i>>8|i>>9)&46&i >>8))^(i&i>>13|i>>6));}" | gcc -x c - && ./a.out | aplay
This is sample output - yours may be different.
Something I pulled off 4chan, it plays a tune.
echo -e "You are a jerk\b\b\b\bwonderful person" | pv -qL $[10+(-2 + RANDOM%5)]
This is sample output - yours may be different.
You are a wonderful person
The output will show jerk, then wonderful person since echo parses the \b character.
echo "|MENU| |DOWN| |UP/BRIGHT| |ENTER| |AUTO| |OFF|"|osd_cat -p bottom -o -40 -i 1575
This is sample output - yours may be different.
I often need to change the brightness of my monitor. The symbols of the sensor buttons are not illuminated and on a black background .... invisible!
Now i use osd_cat instead of a torch ;-)
echo 'flush_all' | nc localhost 11211 -i1 <<< 'quit'
This is sample output - yours may be different.
[21:36:23] mshertzberg:~ $ flush_all
OK
[21:36:24] mshertzberg:~ $
while sleep 1; do (mpc status;mpc currentsong)|awk 'BEGIN{FS=": "}/^Artist:/{r=r""$2};/^Title:/{r=r" - "$2};/^time:/{r=$2" "r};/^state: play/{f=1}END{if(f==1){print r}}'|echo -ne "\e[s\e[0;0H\e[K\e[0;44m\e[1;33m$(cat -)\e[0m\e[u";done &
This is sample output - yours may be different.
132:245 Front 242 - 7Rain [GHost]
Actually this is a shorter version that fits the 255 chars limit of this resource. The full version shows status in the right top corner:
alias mpdd='while sleep 1; do _r=$(awk '\''BEGIN{FS=": "}/^Artist:/{r=r""$2};/^Title:/{r=r" - "$2};/^time:/{r=$2" "r};/^state: play/{f=1}END{if(f==1){print r}}'\'' <(mpc status;mpc currentsong));_l=${#_r};[ $_l -eq 0 ] && continue;[ -z "$_p" ] && _p=$_l;echo -ne "\e[s\e[0;${_p}H\e[K\e[u";_p=$((COLUMNS - _l));echo -ne "\e[s\e[0;${_p}H\e[K\e[0;44m\e[1;33m${_r}\e[0m\e[u";done &'
mpc is defined like this:
function mpc() {
echo "$*" | nc 192.168.1.1 6600
}
find . -type d | while read dir ; do num=`ls -l $dir | grep '^-' | wc -l` ; echo "$num $dir" ; done | sort -rnk1 | head
This is sample output - yours may be different.
A lot of files in one dir is not so cool for filesystem.
scrotit(){ echo "Screenshot in $1 seconds...";scrot -d $1 '%Y%m%d%h.png' -e 'curl -sF file1=@- http://ompldr.org/upload < $f | grep -P -o "(?<=File:).*(http://ompldr.org/.*)\<\/a\>";rm $f'| sed -r 's@.*(http://ompldr.org/\w{1,7}).*@\1@';}
This is sample output - yours may be different.
$ scrotit(){ echo "Screenshot in $1 seconds...";scrot -d $1 '%Y%m%d%h.png' -e 'curl -sF file1=@- http://ompldr.org/upload < $f | grep -P -o "(?<=File:).*(http://ompldr.org/.*)\<\/a\>";rm $f'| sed -r 's@.*(http://ompldr.org/\w{1,7}).*@\1@';}
$ scrotit 5
Sreenshot in 5 seconds...
http://ompldr.org/vZ2pqaQ
$
Take a screenshot, give $1 seconds pause to choose what to screenshot, then upload and get URI of post in ompdlr.org
echo $((RANDOM % 10 + 1))
This is sample output - yours may be different.
If you don't have seq or shuf, bash can be used.
while true;do n="$(curl -s http://news.yahoo.com/rss/|sed 's/</\n/g'|grep "title>"|sed -e '/^\// d' -e 's/title>/---------- /g' -e '1,3d'|tr '\n' ' ')";for i in $(eval echo {0..${#n}});do echo -ne "\e[s\e[0;0H${n:$i:$COLUMNS}\e[u";sleep .15;done;done &
This is sample output - yours may be different.
This creates a permanent stock ticker in the terminal. it has scrolling action and refreshes when each cycle is done to get the latest news.
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
while true; do echo -ne "\e[s\e[0;$((COLUMNS-27))H$(date)\e[u"; sleep 1; done &
This is sample output - yours may be different.
This puts a clock in the top right of the terminal. This version doesn't use tput, but uses escape codes
echo "your string here" | tr '\!-~' 'P-~\!-O'
This is sample output - yours may be different.
%96 BF:4< 3C@H? 7@I ;F>AD @G6C E96 =2KJ 5@8
This command will encode a string using the ROT47 cipher.
java -jar app.jar -cp $(echo lib/*.jar | tr ' ' ':')
This is sample output - yours may be different.
Lauching an app including jars in an adjacent lib folder to its classpath
for k in `git branch -r|awk '{print $1}'`;do echo -e `git show --pretty=format:"%Cgreen%ci_%C(blue)%c r_%Cred%cn_%Creset" $k|head -n 1`$k;done|sort -r|awk -F"_" '{printf("%s %17s %-22s %s\n",$1,$2,$3,$4)}'
This is sample output - yours may be different.
This is sample output - yours may be different.
tail -f /var/log/messages.log | while read line ; do echo $line | cut -d \ -f5- | sed s/\\[[0-9]*\\]// | espeak ; done
This is sample output - yours may be different.
echo /home/foo/dir1/bar | awk -F/ -v OFS=/ '{$3 = "dir2"}1'
This is sample output - yours may be different.
$ echo /home/foo/dir1/bar | awk -F/ -v OFS=/ '{$3 = "dir2"}1'
/home/foo/dir2/bar
Awk replaces the value of a specific field while retaining the field separator "/" .
echo foo | ncat [ip address] [port]
This is sample output - yours may be different.
"foo" if it's working
"Ncat: Connection refused." if it's not
you can use a pair of commands to test firewalls.
1st launch this command at destination machine
ncat -l [-u] [port] | cat
then use this command at source machine to test remote port
echo foo | ncat [-u] [ip address] [port]
First command will listen at specified port.
It will listen TCP. If you use -u option will listen UDP.
Second command will send "foo" through ncat and will reach defined IP and port.
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%
echo "abcdefg"|awk 'BEGIN {FS="''"} {print $2}'
This is sample output - yours may be different.
echo 1268727836 | awk '{print strftime("%c",$1)}'
This is sample output - yours may be different.