| UNIX/Linux Forum Archives · Rules and Guidelines · Disclaimer |
Help
Search
Members
Calendar
|
| Welcome Guest ( Log In | Register ) | Resend Validation Email |
![]() ![]() ![]() |
| maximus |
Posted: Apr 5 2005, 10:11 PM
|
|
Newbie ![]() Group: Members Posts: 3 Member No.: 844 Joined: 3-March 05 |
Hi All,
In my script, I want to read input from another file. The input file contains many lines, however, I only want read certain specific lines as input. example: input.txt test1 test2 test3 bad1 bad2 bad3 In my script, when I use the read command like this: while read line do the entire input file is read, all 6 lines. How can I specify only certain lines as input? Lets say, I only want first 3 lines as input, how can I do that? Thanks in advance. |
| venkat_venkamolla |
Posted: Apr 6 2005, 07:44 AM
|
|
User Level: 2 ![]() ![]() Group: Members Posts: 13 Member No.: 906 Joined: 4-April 05 |
you can do that by selecting the lines into a variable
ex: # here you get the first 3 lines from your file lp_lines=`cat input.txt|head -3` # here you read the each line from the selected in a loop for l_line in ${lp_lines}; do ----done your process here-- done is it ok.... |
| andyb1ack |
Posted: May 12 2005, 02:38 PM
|
||||
|
User Level: 4 ![]() ![]() ![]() ![]() Group: Members Posts: 98 Member No.: 513 Joined: 9-September 04 |
Or in the same vein:
or even
|
||||
![]() |
![]() ![]() ![]() |