The website of Lei Chen

Sunshine and rain of a developer

Archive for the ‘shell’ Category

Bash: Create a variable from several piped commands

Posted by hide1713 on April 19, 2009

Here’s how to put the result of several commands to a variable. This is quite useful.

> echo $(ls|sort|uniq|wc)
14 14 342

Posted in shell | Leave a Comment »

How much do you know about tar?

Posted by hide1713 on November 26, 2008

Tar could be one of most powerful and complex command which we need to use every day. Here some tips for tar

Find file and put them in to tar:

find ./ -name “*.jpg” | tar -cvf yourtar.tar -T -

or

tar -cvf yourtar.tarĀ  `find *.c -print`

Posted in shell | Tagged: | Leave a Comment »

Bash Tip: Execute Command Inside Another Command

Posted by hide1713 on November 26, 2008

There is a way to embeded a command inside another command by using ` key. This key is on the left of 1 key

Example

tar -cvf aa.tar `find *.c -print`

This command finds all the *.c file and send it to aa.tar

Posted in shell | Tagged: | Leave a Comment »

Chmod recursively in directory

Posted by hide1713 on November 14, 2008

Chmod recursively in directory

remove execute from files under aa directory. This is useful when you copy files from fat or ntfs.

find aa/ -type f -exec chmod -x {} \;

Posted in shell | Tagged: , | Leave a Comment »