This command will copy command's output into your local clipboard
This is a equivalent to the GNU ' readlink' tool, but it supports following all the links, even in different directories.
An interesting alternative is this one, that gets the path of the destination file
myreadlink() { [ ! -h "$1" ] && echo "$1" || (local link="$(expr "$(command ls -ld -- "$1")" : '.*-> \(.*\)$')"; cd $(dirname $1); myreadlink "$link" | sed "s|^\([^/].*\)\$|$(dirname $1)/\1|"); }
Show Sample Output
Same as previous but compatible with BSD/IPSO
taken from http://www.unix.com/shell-programming-scripting/158311-how-tee-stderr.html " What does it mean? The redirection operator n>&m makes file descriptor n to be a copy of file descriptor m. So, whe are: - Opening a new file descriptor, 3, that is a copy of file descriptor 1, the standard output; - Making file descriptor 1 a copy of file descriptor 2, the standard error output; - Making file descriptor 2 to be a copy of file descriptor 3 (the "backup" of the standard output) in a short: we swapped the standard output and the standard error output. "
This lists all files modified after calling some command using a temporal anchor.
See "Parameter Expansion" in the bash manpage. They refer to this as "Use Alternate Value", but we're including the var in the at alternative. Show Sample Output
open an application to wherever you like on your current display. the first set of #'s (120x30) denotes size of window opened in, and the second set (+1280+0) identifies the location. Either set can be used alone, or with the other. Also, opening gnome-terminal with this option requires it to be "--geometry" for some reason.
This command line will display the output of , from the first line of output, until the first time it sees a pattern matching . You could specify the regex pattern /^$/ to look for the first blank line, or /^foobar/ to look for the first line that starts with the word foobar.
yt-mp3chanrip() { for count in 1 51 101 151 201 251 301; do for i in $(curl -s http://gdata.youtube.com/feeds/api/users/"$1"/uploads\?start-index="$count"\&max-results=50 | grep -Eo "watch\?v=[^[:space:]\"\'\\]{11}" | uniq); do ffmpeg -i $(wget http://youtube.com/"$i" -qO- | sed -n "/fmt_url_map/{s/[\'\"\|]/\n/g;p}" | sed -n '/^fmt_url_map/,/videoplayback/p' | sed -e :a -e '$q;N;5,$D;ba' | tr -d '\n' | sed -e 's/\(.*\),\(.\)\{1,3\}/\1/') -vn -ab 128k "$(youtube-dl -e http://youtube.com/"$i").mp3"; done; done; unset count i; }
create the function and run with
yt-mp3chanrip YoutubeUsername
Great for channels like ukfDrumAndBass that only post music. No more need for third party browser plugins or websites that only convert one vid one at a time. It'll convert and save to CWD up to 300 of a user's videos to mp3s, one at a time. To increase, just increment the $count pattern. This is a concoction from commands #7718 and #7752, so it uses ffmpeg wget, curl, sed, and youtube-dl -- youtube-dl is only used to get the title of the video which it uses to name the mp3 file. You can use a different naming method if you want and the function should still work.
yt2mp3(){ for j in `seq 1 301`;do i=`curl -s gdata.youtube.com/feeds/api/users/$1/uploads\?start-index=$j\&max-results=1|grep -o "watch[^&]*"`;ffmpeg -i `wget youtube.com/$i -qO-|grep -o 'url_map"[^,]*'|sed -n '1{s_.*|__;s_\\\__g;p}'` -vn -ab 128k "`youtube-dl -e ${i#*=}`.mp3";done;}
squeezed the monster (and nifty ☺) command from 7776 from 531 characters to 284 characters, but I don't see a way to get it down to 255. This is definitely a kludge!
Move efficiently between directories.
.
This command adds a couple of extra features to cd, without affecting normal use.
CDPATH use is also unaffected. It introduces and environment variable CDDIR which is used as an alternate home directory.
.
Note: I don't want to alter $HOME because then all my dot files will move.
.
Examples:
.
cd dir
Change directory to "dir" (using CDPATH if necessary)
.
cd dir/file.txt
Change directory to "dir" (containing folder of "file.txt")
This allows you to cut'n'paste, or use
.
CDDIR is unset
cd
Change directory to $HOME
.
CDDIR=/home/flatcap/work
cd
Change directory to /home/flatcap/work
.
For convenience, put the command, and the following, in your .bashrc or .bash_profile
export CDDIR="/home/flatcap/work"
alias cdd="CDDIR=$(pwd)"
Show Sample Output
Using "func" to run any command and receive output from all your systems. Default output from func is normally meant for further script parsing, but is generally readable. This example shows system arch, but any command can be used and will run as typed. Show Sample Output
Changes dir to $1 and executes ls. As simple as useful Show Sample Output
see: https://groups.google.com/forum/?fromgroups=#!topic/vim_use/e3Er8x_P8jg
Appends output to the file, some systems require the -a to do this.
By adding this to your bashrc, when SSH'ing to a server while screen is active it will change the window tittle to the name of the server you going to. Show Sample Output
This is useful for scripting. Show Sample Output
Use tee -a to append.
Remove all spaces from command's output
Adds the stdout (standard output) to the beginning of logfile.txt. Change "command" to whatever command you like, such as 'ls' or 'date', etc. It does this by adding the output to a temporary file, then adding the previous contents of logfile.txt to the temp file, then copying the new contents back to the logfile.txt and removing the temp file.
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: