for example:
echo "..1234567." | cut -c $(range 3 7)
yields
1234567
I know this has been beaten to death but finding video files using mime types and printing the "hours of video" for each directory is (IMHO) easier to parse than just a single total. Output is in minutes. Among the other niceties is that it omits printing of non-video files/folders PS: Barely managed to fit it within the 255 character limit :D Show Sample Output
From http://daringfireball.net/2009/11/liberal_regex_for_matching_urls Thought it would be useful to commandlinefuers. Show Sample Output
on this way we can define the body too
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 ).
Manpages, command summaries, and pretty much everything else usually have the information you're most likely to want at the beginning. Seeing just the last 40 or so lines of options from a command that has 100 is not super useful, and having to scroll up each time you want to glance at something is spastic.
Run this and then do something like
p do vi --help
and you'll get the first screen(-mostly-)full of vi's usage info and options list
Then use
p d
to page down, and
p u
to page up.
To see the current page again:
p r
Also useful for situations like
p do aptitude search ~dsmorgasbord
p next
#p sudo aptitude -r install libwickedawesome-perl-snoochieboochies
p next
p sudo aptitude -r install libwickedawesome-perl-snoochieboochies snazztasticorama-dev-v0.∞
where you're using readline up-arrow, HOME, END, etc., to quickly recall commented commands.
For the unaware, that option to aptitude search will bring up all of the packages whose descriptions contain the string "smorgasbord". Depending on your distro, there could potentially be hundreds of them.
terms inclosing '()' must be enclosed by "" (soft quotes) bash variables must be referenced: b $x/$y ugly bracket checking (balanced, fractions...) default precision 2 Show Sample Output
the sed way to print a linhe with 50 hyphens
files
Display the $PATH with one line per entry, in a pager. Show Sample Output
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
Col 1 is swapped sum in kb Col 2 is pid of process Col 3 is command that was issued 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 command is jsut for the main IP settings of ndd. if you need ip6 or icmp edit the text within the egrep inclusion area. Felix001 - www.Fir3net.com Show Sample Output
The example is a little bit bogus, but applies to any command that takes a while interactively, or might be a bit of a drag on system resources. Once the command's output is saved to a variable, you can then echo "$OUTPUT" to see it in multi-line glory after that. The use of double-quotes around the backticks and during the variable expansion disables any IFS conversion during those two operations. Very useful for reporting that might pull different lines out, like from dmidecode, inq or any other disk detail command. The only caveat is that storing too much in a variable might make your shell process grow.
scale define the number you want after comma Show Sample Output
In some case, you need to use remote gui on servers or simple machines and it's boring to see "cannot open display on ..." if you forgot to export your display. Juste add this line in .bashrc on remote machine. Dont forget to allow remote client on your local X server :
xhost +
You can do some boolean logic like
A or B then C else D using
or : ||
and : &&
So you can do some :
# false || false && echo true || echo false
false
# true || false && echo true || echo false
true
# false || true && echo true || echo false
true
# true || true && echo true || echo false
true
and so on ...
I use it like :
(ssh example.com 'test something') || $(ssh example.net 'test something') && echo ok || echo ko
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: