Computing.Net > Forums > Linux > help in Bash script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

help in Bash script

Reply to Message Icon

Name: peter bell
Date: April 28, 2003 at 04:29:32 Pacific
OS: linux
CPU/Ram: plll 500 123 mb
Comment:

I need help in Bash script.
1. How to output a particular line of a file eg the 8th line?
2. How to store the output of a command as a variable for later commands?--eg "wc -l filename" will give the number of lines of the file, but how to store this outputed number as a variable for later use ?
Thank You



Sponsored Link
Ads by Google

Response Number 1
Name: David Perry
Date: April 28, 2003 at 04:40:29 Pacific
Reply:

head -8 filename | tail -1

var=`wc -l filename | awk '{ print $1 }'`

echo $var


0
Reply to Message Icon

Related Posts

See More


Public IP routing Perl script is not execut...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: help in Bash script

Separating commands in bash scripts www.computing.net/answers/linux/separating-commands-in-bash-scripts/20341.html

howto put ctrl chars in bash script www.computing.net/answers/linux/howto-put-ctrl-chars-in-bash-script/20213.html

How logout from login-menu bash script? www.computing.net/answers/linux/how-logout-from-loginmenu-bash-script/9016.html