Linux Today: Linux News On Internet Time.
Search Linux Today
Linux News Sections:  Blog -  Developer -  High Performance -  Infrastructure -  IT Management -  Security -  Storage -
Linux Today Navigation
LT Home
Preferences
Contribute
Link to Us
Search
Linux Jobs

Linux Today
Enterprise Linux Today
Apache Today
JustLinux.com
Linux Planet
PHPBuilder
All Linux Devices
Technology Jobs

JustTechJobs.com

LinuxToday Newsletters
Server Daily
IT Management Daily
Subscribe News
Subscribe PR
Subscribe Security

internet.com
Internet News
Small Business

Advertise
Newsletters
Tech Jobs
E-mail Offers

 






Current Newswire:

Using Wii remote with Android Device- Taking Gaming to the Next Level

Commercial Support now available for the open-source NGINX Web server

Linux Top 5: Linux's New Fellow

RebeccaBlackOS - First Live CD Running Wayland Display Server

The Linux powered LAN Gaming House

5 Best Android Apps For Reddit Lovers

SECURITY: Flash Player Sandbox Comes to Firefox

The Future of Kubuntu

SECURITY: Symantec should not be afraid of 'open' source code

Linux 3.3 rc3



Applications Management Engineer Sr (NYC)
Next Step Systems
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume
:Bash Tricks II: Repetitive tasks on files
Bash Tricks II: Repetitive tasks on files
Jun 7, 2009, 14 :02 UTC (0 Talkback[s]) (6639 reads)

(Other stories by Edmundo Carmona)

[ Thanks to Edmundo for this link. ]

"Second we have the while read variable; do x; y; z; done. This construct allows us to read from the standard output line by line placing the content of each line in a variable (multiple variables can be used, in that case a single word from the standard input will be placed in each variable). In our case, we used $filename as our variable (be careful not to use $ on the while read).

"Then the ``s. These kids allow us to run a command so that its output can be assigned. In our case, we are listing the files of a tgz file, grepping to find the pattern of the file we are looking for and then counting the lines that come out of grep. The number of lines is what is saved in the variable $lines."

Complete Story

Related Stories:
Some Howtos: A whole batch from TuxMachines.org(May 30, 2009)
Switch to the Command line, Part 1(May 27, 2009)
Speak UNIX fluently with the best tools available(May 15, 2009)
Use the Bash trap Statement to Clean Up Temporary Files(May 12, 2009)
Command line made easy: five simple recipes for grep(May 06, 2009)
The Tiny Unix And Linux Shell Crash Course For Beginners(May 01, 2009)
/dev/null And /dev/zero On Linux And Unix: What's The Difference?(Apr 29, 2009)
The Bash declare Statement(Apr 29, 2009)



No talkbacks posted.
  Home | Search Talkbacks | Customize View    Top of Page  



Enter your comments below:

* Your Name:

* Your Email Address:

* Subject:

CC: [will also send this talkback to an E-Mail address]

* Comments:

Tags allowed:<I>,<B> and <U>. See our talkback-policy for more about talkback content.

Fields marked with * are required!

..............................




All times are recorded in UTC.
Linux is a trademark of Linus Torvalds.
Powered by Linux, Apache and PHP