read file content


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting read file content
# 1  
Old 12-08-2009
read file content

i have one file

abhi.txt

its contents are

home8/mc09ats/UnixCw/backup/file1
home8/mc09ats/file2

i want to read this content of file using while loop..

in this i want to seperate the content as follows

path=home8/mc09ats/UnixCw/backup
file=file1
echo path
echo file

can you please help me out..
# 2  
Old 12-08-2009
Code:
while read var1;
 do
 path=${var1%/*}; 
 file=${var1##*/}; 
echo "path is $path";
 echo "file is $file";
 done < abc.txt

HTH,
PL
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read and concatenate content file and file name

Hi all, i need a bash script. I have a 3 file named Milano, Torino, Firenze Into file i have: Milano Marco Luca Giorgio Michele PatrizioTorino Marco Giulio Emilio MicheleFirenze Luca Giorgio Marco Saverio EmilioThe output should be a all_city.csv file like: (3 Replies)
Discussion started by: kamose
3 Replies

2. Shell Programming and Scripting

Perl SCript to read file content (if else statemenet)

Hi All, I wanted to write a perl script to read the content in a file,the file content is either 0 (zero) OR 1. The idea is like this. If (content =1), then it will proceed to perform some step. and then update the file content to 0(zero) else if (content =0), it will update the content to... (11 Replies)
Discussion started by: hploh
11 Replies

3. Shell Programming and Scripting

While read line ignores the '\' in file content

I need to read temp.$i file content line by line through while loop but somehow the '\' do not appear in output.. Can someone guide how to read this exact content line by line in unix : if then cat temp.$i | head -1 # the file content appears fine while... (13 Replies)
Discussion started by: Prev
13 Replies

4. Shell Programming and Scripting

cut the variable from the line and use it to find the file and read the content of that file

Hi, I am working on one script..I am having files in the below format file 1 (each line is separated with : delimeter) SPLASH:SPLASH:SVN CIB/MCH:MCH:SVN Now I want from file 1 that most left part of the first line will store in... (6 Replies)
Discussion started by: rohit22hamirpur
6 Replies

5. Shell Programming and Scripting

Read a text file and print the content..

hello all i request you to give the solution for the following problem.. I want read the text file.and print the contents character by character..like if the text file contains google means..i want to print g go goo goog googl google like this Using unix Shell scripting... ... (7 Replies)
Discussion started by: samupnl
7 Replies

6. Shell Programming and Scripting

How to read file and only output certain content

Hi - I have a file containing data like :- cn=tommy,cn=users,c=uk passwordexpirydate=20100530130623z cn=jane,cn=users,c=uk passwordexpirydate=20100423140734z cn=michael,cn=users,c=uk passwordexpirydate=20100331020044z I want to end up with a file that looks like:-... (6 Replies)
Discussion started by: sniper57
6 Replies

7. Shell Programming and Scripting

Read a file content with awk and sed

Hello , I have huge file with below content. I need to read the numeric values with in the paranthesis after = sign. Please help me with awk and sed script for it. 11.10.2009 04:02:47 Customer login not found: identifier=(0748502889) prefix=(TEL) serviceCode=(). 11.10.2009 04:03:12... (13 Replies)
Discussion started by: rmv
13 Replies

8. Shell Programming and Scripting

read a file and use the content for mapping

help me pls.. :( i want to read a mapping file. Below is the content of my mapping file. 6221,189,SMSC1,OMC1,WAP1 6223,188,SMSC2,OMC2,WAP2 so when my program running msisdn="622130302310" while not EOF if substring($msisdn,1,4) == "6221" -- > "6221" read from the file then echo... (0 Replies)
Discussion started by: voidmain
0 Replies

9. Shell Programming and Scripting

Need help with awk - how to read a content of a file from every file from file list

Hi Experts. I need to list the file and the filename comes from the file ListOfFile.txt. Basicly I have a filename "ListOfFile.txt" and it contain Example of ListOfFile.txt /home/Dave/Program/Tran1.P /home/Dave/Program/Tran2.P /home/Dave/Program/Tran3.P /home/Dave/Program/Tran4.P... (7 Replies)
Discussion started by: tanit
7 Replies

10. Shell Programming and Scripting

How to read the content of the particular file from tar.Z without extracting?

Hi All, I want to read the content of the particular file from tar.Z without extracting. aaa.tar.Z contains a file called one.txt, I want to read the content of the one.txt without extracting. Please help me to read the content of it. Regards, Kalai. (12 Replies)
Discussion started by: kalpeer
12 Replies
Login or Register to Ask a Question