
Terminal - All commands - 10,551 results
case $# in 0) echo usage: $0 pattern ;; *)case $1 in */*)sed ' s,'"$1"',\ ,g';; *) sed ' s/'"$1"'/\ /g' ;;esac;esac;
This is sample output - yours may be different.
alternative to tr char '\012'
works with sed's that don't accept "\n"
allows for multi-char sentinals, while tr(1) only operates on single chars
This is sample output - yours may be different.
i686 = 32 bits
x86_64 = 64 bits
the command "getconf LONG_BIT" will work just as well.
This is sample output - yours may be different.
# cat file1.mp3 file2.mp3 > file3.mp3
This is sample output - yours may be different.
cat - concatenate MP3 files and save it...
This is sample output - yours may be different.
source filename_script.sh
This is sample output - yours may be different.
Useful command to avoid unreadble script in a single file...
v () { echo "$@"; "$@"; }
This is sample output - yours may be different.
$ v rm -v *~
rm -v example~
removed `example~'
You can use this in shell scripts to show which commands are actually run. Just prepend every "critical line" with "v˽".
$TMP=/tmp
echo "Let me create a directory for you"
v mkdir $TMP/new
In scripts this can be more useful than "set -x", because that can be very verbose with variable assignments etc.
Another nice use is if you prepend every "critical" command with "v", then you can test your script by commenting out the actual execution.
man $(/bin/ls /bin | awk '{ cmd[i++] = $0 } END { srand(); print cmd[int(rand()*length(cmd))]; }')
This is sample output - yours may be different.
Build an awk array with all commands and then select a random one at the end.
This avoids spawning extra processes for counting with wc or generating random numbers.
Explicitly call /bin/ls to avoid interactions with aliases.
not () { "$@" && return 1 || return 0; }
This is sample output - yours may be different.
Useful in while and if statements
if not grep string filename; then echo string not found; exit 1; fi
This is sample output - yours may be different.
export IFS=$'\n';for dir in $( ls -l | grep ^d | cut -c 52-);do du -sh $dir; done
This is sample output - yours may be different.
cat file.txt|perl -ne '$_=~s/\s+/\n/g; print $_;'
This is sample output - yours may be different.
This command is useful for separating a text file where all the words are in one line. Any group of spaces will be replaced with a single newline. Instead of one long line of tokens. You'll have a long list of tokens. One token per line.
ps aux | grep [c]ommandname
This is sample output - yours may be different.
x=192.168.1.1; whois $x > $x.txt
This is sample output - yours may be different.
#
# Query terms are ambiguous. The query is assumed to be:
# "n 192.168.1.1"
#
# Use "?" to get help.
#
#
# The following results may also be obtained via:
# http://whois.arin.net/rest/nets;q=192.168.1.1?showDetails=true&showARIN=false
#
NetRange: 192.168.0.0 - 192.168.255.255
CIDR: 192.168.0.0/16
OriginAS:
NetName: PRIVATE-ADDRESS-CBLK-RFC1918-IANA-RESERVED
NetHandle: NET-192-168-0-0-1
Parent: NET-192-0-0-0-0
NetType: IANA Special Use
NameServer: BLACKHOLE-1.IANA.ORG
NameServer: BLACKHOLE-2.IANA.ORG
Comment: This block is used as private address space.
Comment: Addresses from this block can be used by
Comment: anyone without any need to coordinate with
Comment: IANA or an Internet registry. Addresses from
Comment: this block are used in multiple, separately
Comment: operated networks.
Comment: This block was assigned by the IETF in the
Comment: Best Current Practice document, RFC 1918
Comment: which can be found at:
Comment: http://www.rfc-editor.org/rfc/rfc1918.txt
RegDate: 1994-03-15
Updated: 2010-03-15
Ref: http://whois.arin.net/rest/net/NET-192-168-0-0-1
OrgName: Internet Assigned Numbers Authority
OrgId: IANA
Address: 4676 Admiralty Way, Suite 330
City: Marina del Rey
StateProv: CA
PostalCode: 90292-6695
Country: US
RegDate:
Updated: 2004-02-24
Ref: http://whois.arin.net/rest/org/IANA
OrgTechHandle: IANA-IP-ARIN
OrgTechName: Internet Corporation for Assigned Names and Number
OrgTechPhone: +1-310-301-5820
OrgTechEmail: abuse@iana.org
OrgTechRef: http://whois.arin.net/rest/poc/IANA-IP-ARIN
OrgAbuseHandle: IANA-IP-ARIN
OrgAbuseName: Internet Corporation for Assigned Names and Number
OrgAbusePhone: +1-310-301-5820
OrgAbuseEmail: abuse@iana.org
OrgAbuseRef: http://whois.arin.net/rest/poc/IANA-IP-ARIN
#
# ARIN WHOIS data and services are subject to the Terms of Use
# available at: https://www.arin.net/whois_tou.html
#
This can be used in scripts, to find out the origin of target IP etc.
This is sample output - yours may be different.
printf "$string" | md5sum
This is sample output - yours may be different.
echo -en "$USER@$HOSTNAME:${PWD##*/}> ";while read x;do echo $x>>/tmp/log.txt;echo $x|$0 2>&1;echo -en "$USER@$HOSTNAME:${PWD##*/}> ";done
This is sample output - yours may be different.
files=(/usr/share/cowsay/cows/*); cowsay -f `echo ${files[$((RANDOM%${#files}))]}` <TEXT>
This is sample output - yours may be different.
This will show a random cow with cowsay.
find . |more |grep -v filename |xargs rm
This is sample output - yours may be different.
awk '{if (NR == 3) print}' <file>
This is sample output - yours may be different.
I don't know if it's better but works fine :)
gawk '{n=$1;a=0;b=1;c=1;for(i=1;i<n;i++){c=a+b;a=b;b=c};print c}' << eof
This is sample output - yours may be different.
finish input with:
999
0
1
2
3
eof
26863810024485337815052569207027905710267776959038865271418527606059667101451514099303873236210167827650084004405807693119964697202348044908203804335127173454055409270617765081794282450393830849992803129229312
1
1
1
2
only take the first field on each row to compute the fibo on this number
find . -name "*.c" -exec sed -i "/\/sh/a\####################################\n#Date:2010-05-18\n#Company:XXXXX tech Co.\n#Author:Wangjunling\n#Copyright:gpl\n####################################" {} \;
This is sample output - yours may be different.
This is sample output - yours may be different.
removedir(){ read -p "Delete the current directory $PWD ? " human;if [ "$human" = "yes" ]; then [ -z "${PWD##*/}" ] && { echo "$PWD not set" >&2;return 1;}; rm -Rf ../"${PWD##*/}"/ && cd ..; else echo "I'm watching you" | pv -qL 10; fi; }
This is sample output - yours may be different.
[user@host foo]$ removedir
Delete the current directory /home/user/asdf/.hidden/a b c/foo ? no
I'm watching you
[user@host foo]$ removedir
Delete the current directory /home/user/asdf/.hidden/a b c/foo ? yes
[user@host a b c]$ removedir
Delete the current directory /home/user/asdf/.hidden/a b c ? yes
[user@host .hidden]$ removedir
Delete the current directory /home/user/asdf/.hidden ? yes
[user@host asdf]$ unset PWD
[user@host asdf]$ removedir
Delete the current directory ? yes
$PWD not set
[user@host asdf]$
May want to change echos to more descriptive (more than 255 characters) such as:
$ removedir(){ read -p "You are about to delete the current directory $PWD Are you sure? " human;if [ "$human" = "yes" ]; then [ -z "${PWD##*/}" ] && { echo "Error: Couldn't get working directory" >&2;return 1;}; rm -Rf ../"${PWD##*/}"/ && cd ..; else echo "I'm watching you" | pv -qL 10; fi; }
Credit goes to "eightmillion"
say `cat /path/to/textfile.txt`
This is sample output - yours may be different.