commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
Replace all instances of "A" with "B" in file "source" saved as file "destination".
!! IF A/B is multi-byte, then separate bytes with spaces like so: "s/20\ 0A/00/g".
I used this fragment with Imagemagick convert so that I can place long text strings in pictures. The "\n" gets converted to a true newline in the image.
So this fragment uses fold command to wrap the line and then sed to convert newlines (and any trailing spaces on the line) to the text "\n"
This command is similar to the alternate, except with head(1), you can pick as many passwords as you wish to generate by changing the number of lines you wish to preview.
Replaces hexdump with the more succint xxd, and the sed was unnecessarily complex.
I look at xkcd in my news reader, but it displays the image's title attribute only for a few seconds which makes reading the longer ones more challenging. So I use this to display it in my console.
od /dev/urandom -w60 -An|sed 's/ ..../ /g'|head -n 30
(this one lacks digits 8 and 9)
Generate a 18 character password from character set a-zA-Z0-9 from /dev/urandom, pipe the output to Python which prints the password on standard out and in crypt sha512 form.
Like 7171, but fixed typo, uses fewer variables, and even more cryptic!
no need that useless cat.
Per default, linux/unix shells are configured with a width of 80 characters.
If you like to edit a phrase or string on a line with more than 80 characters it might take long to go there (for example a line with 1000 characters and you like to edit the 98th word which is character 598-603).
Maybe you might wish to use 78 characters, because if you forward the text via mail and the text will be quoted (2 extra characters at the beginning to the line "> "), you use 80 characters, otherwise 82, which are lame.
wraps text lines at the specified width (90 here).
-s option is to force to wrap on blank characters
-b count bytes instead of columns
This will view the console and assumes the screen is 80 characters wide.
Use /dev/vcs2 for the next virtual console.. etc.
fold wraps text at 80 characters wide, and with the -s flag, only causes wrapping to occur between words rather than through them.