The $[...] block in bash and zsh will let you do math.
echo $[6*7]
This is the same as using $((...)), which also works in ksh. Of course, this is a simple, dumb wrapper and doesn't allow floating-point.
Show Sample Output
Renames all the jpg files as their timestamps with ".jpg" extension. Show Sample Output
Same thing, only "head" instead of grep/egrep.. Show Sample Output
uses the previous "chr" function and uses it to create the inverse function "ord" by brute force. It's slow, It's inelegant, but it works. I thought I needed ord/chr to do a cartesian cipher in shell script a whie ago, but eventualy I realized I could get fancy with tr and do the same thing...
This assumes that te original's 'passwd -e' forces a user to change password; it doesn't in the versions I have.
man 5 shadow
I think it's more reliable, because
passwd -S
dont show "locked" but "L" as second field on my Archlinux for a particular user.
( unixhome alternative ).
My old Solaris server does not have lsof, so I have to use pfiles.
This command will play back each keystroke in a session log recorded using the script command. You'll need to replace the ^[ ^G and ^M characters with CTRL-[, CTRL-G and CTRL-M. To do this you need to press CTRL-V CTRL-[ or CTRL-V CTRL-G or CTRL-V CTRL-M.
You can adjust the playback typing speed by modifying the sleep.
If you're not bothered about seeing each keypress then you could just use:
cat session.log
Show Sample Output
If you need to randomize the lines in a file, but have an old sort commands that doesn't support the -R option, this could be helpful. It's easy enough to remember so that you can create it as a script and use that. It ain't real fast. It ain't safe. It ain't super random. Do not use it on untrusted data. It requires bash for the $RANDOM variable to work. Show Sample Output
This is not recommended... lossy -> lossy = lossier. Still, you can do it! ;)
If you want to relocate a package on your own, or you just want to know what those PREIN/UN and POSTIN/UN scripts will do, this will dump out all that detail simply. You may want to expand the egrep out other verbose flags like CHANGELOGTEXT etc, as your needs require. It isn't clear, but the formatting around $tag is important: %{$tag} just prints out the first line, while [%{$tag }] iterates thru multi-line output, joining the lines with a space (yes, there's a space between the g and } characters. To break it out for all newlines, use [%{$tag\n}] but the output will be long. This is aside from rpm2cpio | cpio -ivd to extract the package files.
Thanks th John_W for suggesting the fix allowing ~/ to be used when saving a directory. directions: Type in a url, it will show a preview of what the file will look like when saved, then asks if you want to save the preview and where you want to save it. Great for grabbing the latest commandlinefu commands without a full web browser or even a GUI. Requires: w3m 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
Say you want to time how long a task you're performing takes. Start this simple timer and you're done! Show Sample Output
This command finds all of the functions defined in any shell script you specify including .bashrc
can also be invoked as 'exipick -zi | exim -dM' if you do not need/want the delay between flushes.
i use this after ripping internet radio streams to number the files as they originally played (even though streamripper can do this with -q). to number other types of files, or all files, just change the *mp3. to rename directories only you could use ... ls -lt | grep ^d | cut -d ":" -f2 | cut -d " " -f2- | while read ... Show Sample Output
just an alternative to #7818 Show Sample Output
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: