Really, you deserve whatever happens if you have a whitespace character in a file name, but this has a small safety net. The truly paranoid will use '-i'.
requires "youtube-dl" -- sure you can do this with wget and some more obscurity but why waste your time when this great tool is available?
the guts consist of mplayer converting a video to a gif -- study this command and read the man page for more information
mplayer video.flv -ss 00:23 -endpos 6 -vo gif89a:fps=5:output=output.gif -vf scale=400:300 -nosound
generates a 6 second gif starting at 23 seconds of play time at 5 fps and a scale of 400x300
start time (-ss)/end time (-endpos) formats: 00:00:00.000
end time should be relative to start time, not absolute. i.e. -endpos 5 == seconds after 0:42 = 0:47 end point
play with fps and scale for lower gif sizes
the subshell is a solution for the -b flag on youtube-dl which downloads the best quality video, sometimes, which can be various video formats $(ls ${url##*=}*| tail -n1)
Show Sample Output
Takes all .flac directories, feeds them into a simple transcode pipeline to spit out .wavs with the same name (but correct extension).
This will list all symlinks that are directories under the current directory. This will help you distinguish them from regular files.
forces user to rw, group to r, and other to no access. files will not be marked executable. directories will be executable for users and groups only. Show Sample Output
Replace the echo command with whatever commands you want. 'read' reads a line from stdin and places the text in the variable, the stdin of the while loop comes from the find command. Note that with simple commands, an easier way is using the '-exec' option of find. My command is useful if you want to execute multiple commands in the loop. Show Sample Output
Fdiff will run the command given by the first argument against the input files given as the second and third arguments, and diff the results.
It will use 'diff' as the default diff program, but this can be changed by setting $DIFFCMD, e.g.
export DIFFCMD=vimdiff;
fdiff zcat 0716_0020005.raw.gz 0716_0030005.raw.gz
...
This function will work under bash, but requires the use of command substitution, which is not available under a strict ANSI shell.
Show Sample Output
Better tool for exporting git's repository is Git itself!
% = buffer d = delete
This will cause bash to fix a garbled terminal before the prompt is printed. For example, if you cat a file with nonprintable character sequences, the terminal sometimes ends up in a mode where it only prints line drawing characters. This sequence will return the terminal to the standard character set after every command.
I used to do a lot of path manipulation to set up my development environment (PATH, LD_LIBRARY_PATH, etc), and one part of my environment wasn't always aware of what the rest of the environment needed in the path. Thus resetting the entire PATH variable wasn't an option; modifying it made sense.
The original version of the functions used sed, which turned out to be really slow when called many times from my bashrc, and it could take up to 10 seconds to login. Switching to parameter substitution sped things up significantly.
The commands here don't clean up the path when they are done (so e.g. the path gets cluttered with colons). But the code is easy to read for a one-liner.
The full function looks like this:
remove_path() {
eval PATHVAL=":\$$1:"
PATHVAL=${PATHVAL//:$2:/:} # remove $2 from $PATHVAL
PATHVAL=${PATHVAL//::/:} # remove any double colons left over
PATHVAL=${PATHVAL#:} # remove colons from the beginning of $PATHVAL
PATHVAL=${PATHVAL%:} # remove colons from the end of $PATHVAL
export $1="$PATHVAL"
}
append_path() {
remove_path "$1" "$2"
eval PATHVAL="\$$1"
export $1="${PATHVAL}:$2"
}
prepend_path() {
remove_path "$1" "$2"
eval PATHVAL="\$$1"
export $1="$2:${PATHVAL}"
}
I tried using regexes to make this into a cleaner one-liner, but remove_path ended up being cryptic and not working as well:
rp() { eval "[[ ::\$$1:: =~ ^:+($2:)?((.*):$2:)?(.*):+$ ]]"; export $1=${BASH_REMATCH[3]}:${BASH_REMATCH[4]}; };
Show Sample Output
There once was a day I needed this info. Show Sample Output
Essentially the same as funky's alias, but will not traverse filesystems and has nicer formatting. Show Sample Output
The command generate an huge output file (depending on screen resolution and time).
a brief list of very common special characters in Dutch. Usefull for formatting Word source to html.
this oneliner uses make and it's jobserver for parallel execution of your script. The '-j' flag for make defines number of subprocesses to launch, '-f' tells make use stdin instead of Makefile. Also make have neat flag '-l', which "Specifies that no new jobs (commands) should be started if there are others jobs running and the load is at least load (a floating-point number)."
Also you can use plain Makefile, for better readability:
targets = $(subst .png,.jpg,$(wildcard *.png))
(targets):
echo convert $(subst .jpg,.png,$@) $@
all : $(targets)
vlock command locks the current console by default. Also you can lock all the consoles on the server by using -a parameter. For details, pl man vlock. ps: Generally speaking , system will not install vlock programme . So you should use ' $ sudo apt-get install vlock ' to install vlock . Show Sample Output
nmap for windows and other platforms is available on developer's site: http://nmap.org/download.html nmap is robust tool with many options and has various output modes - is the best (imho) tool out there.. from nmap 5.21 man page: -oN/-oX/-oS/-oG : Output scan in normal, XML, s| Show Sample Output
I have come across a situation in the past where someone has unlinked a file by running an 'rm' command against it while it was still being written to by a running process.
The problem manifested itself when a 'df' command showed a filesystem at 100%, but this did not match the total value of a 'du -sk *'.
When this happens, the process continues to write to the file but you can no longer see the file on the filesystem. Stopping and starting the process will, more often than not, get rid of the unlinked file, however this is not always possible on a live server.
When you are in this situation you can use the 'lsof' command above to get the PID of the process that owns the file (in the sample output this is 23521).
Run the following command to see a sym-link to the file (marked as deleted):
cd /proc/23521/fd && ls -l
Truncate the sym-link to regain your disk space:
> /proc/23521/fd/3
I should point out that this is pretty brutal and *could* potentially destabilise your system depending on what process the file belongs to that you are truncating.
Show Sample Output
Gnu grep allows to restrict the search to files only matching a given pattern. It also allows to exclude files.
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: