_ff(){ cd /mnt; echo /mnt/*/* |sed ' s/ \/mnt\//\&/g; '|sed '/'"$1"'/!d'; cd -; } ff(){ case $# in 0) echo "usage: ff glob [sed-cmds] [--|var-name]" ;; 1) _ff $1 |sed = ;; [2-9]) case $2 in --) _ff $1 |less -SN ;; *) _ff $1 |sed -n ''"$2"''|tr '\n' '\040' |sed 's/.*/export '"$3"'=\"&/;s/=\" /=\"/;s/ $/\"/' > $HOME/.ff; case $# in 3) . $HOME/.ff ;; esac; sed ' s/export .*=\"/\$'"$3"' = \"/;' $HOME/.ff;\ ;; esac ;; esac; } v(){ local a=$HOME; sed ' s/export /less -n \$/; s/=.*//; ' $a/.ff > $a/.v ; . $a/.v ; } Another approach using ls(1) lsl(){ _lsl () { ls -l $3 /mnt/*/$1* 2>/dev/null; }; case $# in 0) echo "usage: lsl pat [ls-options|result-no]"; echo "usage: lsle pat [sed-cmds]" ;; 1) _lsl $1 |sed = ;; 2) case $2 in -*) _lsl $1 $@;; *) _lsl $1 |sed 's/.* //; '"$2"'!d; '"$2"'q' > $HOME/.lsl ; export v=$(sed 1q $HOME/.lsl); echo \$v = $v ;; esac ;; esac; } exp(){ echo "%s/\$/ /"; echo "%j"; echo "s/^/export v=\""; echo "s/\$/\""; echo "s/ \"\$/\""; echo "."; echo "wq"; } lsle(){ lsl $1 -1 |sed $2 > .lsl&& exp |ed -s .lsl >&-&& . .lsl&& echo \$v = $v; }
When you SSH to a server who's hostname or IP has changed since the last time a connection was recorded in the known_hosts file a warning will be displayed since this indicated a possible DNS spoofing attack. If this is a known change then this command will remove the previous entry and allow the SSH connection. The SSH client will prompt you as if it was the first time connected to the server. Replace ${LINE} with the line of the offending key in ~known_hosts. 49 in the sample output. Show Sample Output
Enable root user to run VLC
Use optimized sed to big file/stream to reduce execution time
Use
sed '/foo/ s/foo/foobar/g' <filename>
insted of sed
's/foo/foobar/g' <filename>
You need curl.. and a Mac of course.
Esse comando procura por arquivos php que que iniciem com ' Show Sample Output
This works in multiple unixes, not only linux, for different paths. On solaris, if you do not have which, you can use: ksh whence -p anypath/a_command.sh | sed "s|^./|$(pwd)|" ksh whence -p Show Sample Output
Remove all zero size files from current directory. Its a not recursive option like: find . -size 0c -exec rm {} \;
Use the -a flag to display all files, including hidden files. If you just want to display regular files, use a -1 (yes, that is the number one). Got this by RTFM and adding some sed magic. [bbbco@bbbco-dt ~]$ ls -a | sed "s#^#${PWD}/#" /home/bbbco/. /home/bbbco/.. /home/bbbco/2011-09-01-00-33-02.073-VirtualBox-2934.log /home/bbbco/2011-09-10-09-49-57.004-VirtualBox-2716.log /home/bbbco/.adobe /home/bbbco/.bash_history /home/bbbco/.bash_logout /home/bbbco/.bash_profile /home/bbbco/.bashrc ... [bbbco@bbbco-dt ~]$ ls -1 | sed "s#^#${PWD}/#" /home/bbbco/2011-09-01-00-33-02.073-VirtualBox-2934.log /home/bbbco/2011-09-10-09-49-57.004-VirtualBox-2716.log /home/bbbco/cookies.txt /home/bbbco/Desktop /home/bbbco/Documents /home/bbbco/Downloads ... Show Sample Output
Normally, if you just want to see directories you'd use brianmuckian's command 'ls -d *\', but I ran into problems trying to use that command in my script because there are often multiple directories per line. If you need to script something with directories and want to guarantee that there is only one entry per line, this is the fastest way i know Show Sample Output
This works just like write or wall ... cept one thing the sender is anonymous ... if you really want to drive everyone insane replace echo \"The Matrix has you...\" with cat /dev/urandom nice one to do on April fool's day Show Sample Output
I have this as a file called deletekey in my ~/bin. Makes life a little easier.
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: