Ir para o conteúdo
ou

Software livre Brasil

Tela cheia Sugerir um artigo
 Feed RSS

CommandLineFu

4 de Junho de 2009, 0:00 , por Software Livre Brasil - | Ninguém está seguindo este artigo ainda.

Troca de conhecimentos sobre o uso da linha de comando e referencia direta ao site commandlinefu.com.


Define a quick calculator function

29 de Junho de 2009, 0:00, por Software Livre Brasil - 0sem comentários ainda$ ? () { echo "$*" | bc -l; }

defines a handy function for quick calculations from cli.

once defined:

? 10*2+3 (by fizz)

commandlinefu.com

by David Winterbottom (codeinthehole.com)



Create a system overview dashboard on F12 key

25 de Junho de 2009, 0:00, por Software Livre Brasil - 0sem comentários ainda$ bind '"\e[24~"':"\"ps -elF;df -h;free -mt;netstat -lnpt;who -a\C-m"""

Command binds a set of commands to the F12 key.

Feel free to alter the dashboard according to your own needs.

How to find the key codes?

Type

read

Then press the desired key (example: F5)

^[[15~

Try

bind '"\e[15~"':"\"ssh su@ip-address\C-m"""

or

bind '"\e[16~"':"\"apachectl -k restart\C-m""" (by Neo23x0)

commandlinefu.com

by David Winterbottom (codeinthehole.com)



Multiple SSH Tunnels

25 de Junho de 2009, 0:00, por Software Livre Brasil - 0sem comentários ainda$ ssh -L :: -L :: @

Thankfully, the ssh command allows you to specify multiple tunnels through the same server in one command.

Remeber if you want a priviliged port on your machine, you must use root or sudo account.

(by starchox)

commandlinefu.com

by David Winterbottom (codeinthehole.com)



Reuse all parameter of the previous command line

23 de Junho de 2009, 0:00, por Software Livre Brasil - 0sem comentários ainda$ !*

!* is all of the arguments to the previous command rather than just the last one.

This is useful in many situations.

Here's a simple example:

vi cd /stuff

oops!

[exit vi, twice]

!*

expands to: cd /stuff

Submitted by Neo23x0

Options:

commandlinefu.com by David Winterbottom



Display a cool clock on your terminal

21 de Junho de 2009, 0:00, por Software Livre Brasil - 0sem comentários ainda$ watch -t -n1 "date +%T|figlet"

This command displays a clock on your terminal which updates the time every second. Press Ctrl-C to exit.

A couple of variants:

A little bit bigger text:

watch -t -n1 "date +%T|figlet -f big"

You can try other figlet fonts, too.

Big sideways characters:

watch -n 1 -t '/usr/games/banner -w 30 $(date +%M:%S)'

This requires a particular version of banner and a 40-line terminal or you can adjust the width ("30" here).

Submitted by dennisw

Options:

commandlinefu.com by David Winterbottom



Inserts the results of an autocompletion in the command line

15 de Junho de 2009, 0:00, por Software Livre Brasil - 0sem comentários ainda$ ESC *

Pressing ESC then * will insert in the command line the results of the autocompletion.

It's hard to explain but if you look the sample output or do

echo ESC *

you will understand quickly.

By the way, few reminders about ESC :

- Hold ESC does the same thing as tab tab

- 'ESC .' inserts the last argument of last command (can be done many times in order to get the last argument of all previous commands)

Submitted by Josay

Options:

commandlinefu.com by David Winterbottom



Open Finder from the current Terminal location

10 de Junho de 2009, 0:00, por Software Livre Brasil - 0sem comentários ainda$ open .

I did not know this, i'd like to share...

Submitted by vigo

Options:

commandlinefu.com by David Winterbottom



Save an HTML page, and covert it to a .pdf file

10 de Junho de 2009, 0:00, por Software Livre Brasil - 0sem comentários ainda$ wget $URL -O page.html ; htmldoc --webpage -f page.pdf page.html; xpdf page.pdf &

Uses htmldoc to perform the conversion

Submitted by darth10

Options:

commandlinefu.com by David Winterbottom



DELETE all those duplicate files but one based on md5 hash comparision in the current directory tree

10 de Junho de 2009, 0:00, por Software Livre Brasil - 0sem comentários ainda$ find . -type f -print0|xargs -0 md5sum|sort|perl -ne 'chomp;$ph=$h;($h,$f)=split(/\s+/,$_,2);print "$f"."\x00" if ($h eq $ph)'|xargs -0 rm -v --

This one-liner will the *delete* without any further confirmation all 100% duplicates but one based on their md5 hash in the current directory tree (i.e including files in its subdirectories).

Good for cleaning up collections of mp3 files or pictures of your dog|cat|kids|wife being present in gazillion incarnations on hd.

md5sum can be substituted with sha1sum without problems.

The actual filename is not taken into account-just the hash is used.

Whatever sort thinks is the first filename is kept.

It is assumed that the filename does not contain 0x00.

As per the good suggestion in the first comment, this one does a hard link instead:

find . -xdev -type f -print0 | xargs -0 md5sum | sort | perl -ne 'chomp; $ph=$h; ($h,$f)=split(/\s+/,$_,2); if ($h ne $ph) { $k = $f; } else { unlink($f); link($k, $f); }'
Submitted by masterofdisaster

Options:

commandlinefu.com by David Winterbottom



Record a screencast and convert it to an mpeg

8 de Junho de 2009, 0:00, por Software Livre Brasil - 0sem comentários ainda$ ffmpeg -f x11grab -r 25 -s 800x600 -i :0.0 /tmp/outputFile.mpg

Grab X11 input and create an MPEG at 25 fps with the resolution 800x600

Submitted by dcabanis

Options:

commandlinefu.com by David Winterbottom



Tags deste artigo: cli commandline unix terminal