Access line by line from a file with shell script | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Access line by line from a file with shell script

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-21-2013
ramreddy502 ramreddy502 is offline
Registered User
 
Join Date: Jun 2013
Last Activity: 21 June 2013, 10:06 AM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Access line by line from a file with shell script

hello

i want to access line by line from a file and print that line every time can i have a shell script for doing this

thanks
Sponsored Links
    #2  
Old 06-21-2013
rbatte1 rbatte1 is offline Forum Staff  
Moderator
 
Join Date: Jun 2007
Last Activity: 22 October 2014, 11:39 AM EDT
Location: Lancashire, UK
Posts: 1,868
Thanks: 599
Thanked 322 Times in 290 Posts
I think you are after a loop for reading and processing records in your file, else just running:-
Code:
cat filename

would be all that you need.

Can you explain the process you are trying to achieve a bit better. Just something like "I want to print every line in a file" will not get much help. What do you want to do with each line? Is it every line? Do you want to select some lines by content, line number, join lines up or anything?



Thanks, in anticipation,

Robin
Liverpool/Blackburn
UK
Sponsored Links
    #3  
Old 06-21-2013
ramreddy502 ramreddy502 is offline
Registered User
 
Join Date: Jun 2013
Last Activity: 21 June 2013, 10:06 AM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
thanks for your response

actually i have a list of path names in a text file line by line, each and every time i need to access a path name from the file and i need to use that path in the program to access a formatted file present in that path name this process should be run like loop.

my text file contains path names like this

"ram/abc/1
ram/abc/2
ram/abc/3
ram/abc/4
"
in a loop i need to access first path name and i want to access file present in that after this i need to access second path name that is also used for the same purpose

thank you
    #4  
Old 06-21-2013
rbatte1 rbatte1 is offline Forum Staff  
Moderator
 
Join Date: Jun 2007
Last Activity: 22 October 2014, 11:39 AM EDT
Location: Lancashire, UK
Posts: 1,868
Thanks: 599
Thanked 322 Times in 290 Posts
Please use the code tags to wrap around your output.

Consider the loop:-
Code:
#!/bin/ksh
while read dir
do
   echo "Working on directory $dir"
   some processing here
done < input_file

Does that structure help? For each line in the input file, it will print out the message and anything else you care to insert.



I hope that this helps.

Robin
Liverpool/Blackburn
UK
Sponsored Links
    #5  
Old 06-21-2013
ramreddy502 ramreddy502 is offline
Registered User
 
Join Date: Jun 2013
Last Activity: 21 June 2013, 10:06 AM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
thank you very much

it works for me
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
HELP: Shell Script to read a Log file line by line and extract Info based on KEYWORDS matching biztank Shell Programming and Scripting 8 07-24-2012 11:44 PM
Shell script to read multiple options from file, line by line haggismn Shell Programming and Scripting 1 06-09-2012 09:45 PM
Shell script to read a text file line by line & process it... new_to_shell Shell Programming and Scripting 8 09-13-2011 04:45 AM
get the fifth line of a text file into a shell script and trim the line to extract a WORD venu Shell Programming and Scripting 3 12-08-2010 08:46 PM
shell script to read a line in gps receiver log file and append that line to new file gudivada213 Shell Programming and Scripting 3 06-24-2009 06:16 AM



All times are GMT -4. The time now is 07:05 PM.