LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   commands for bash script that handles files of varying number of lines (https://www.linuxquestions.org/questions/linux-newbie-8/commands-for-bash-script-that-handles-files-of-varying-number-of-lines-658399/)

BBFeltham 07-26-2008 10:15 AM

commands for bash script that handles files of varying number of lines
 
Need commands for bash schell script that handles files varying in number of lines.

Nylex 07-26-2008 10:18 AM

You can use wc to get the number of lines in a file (the option -l does this). Edit: you can also store the output of a command in a variable with syntax like this:

variable=`command`

For example, to put the number of lines in the file foo in a variable called num_lines, you'd use the following:

num_lines=`wc -l foo`


All times are GMT -5. The time now is 07:51 PM.