Extracting data from each line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extracting data from each line
# 1  
Old 04-26-2006
Extracting data from each line

Hi All

I have one file aa.txt like this

Code:
Change 172453 on 2006/04/26 10:45:45 by cm@cm-ixca-cm-build23 'cmbuild: ixweb-3.10.28.110 '
Change 172362 on 2006/04/26 08:58:47 by cm@cm-ixca-cm-build23 'build failed: ixweb-3.10.28.109'
Change 172299 on 2006/04/26 07:39:08 by cm@cm-ixca-cm-build23 'build failed: ixweb-3.10.28.108'
Change 172214 on 2006/04/26 05:24:30 by cm@cm-ixca-cm-build23 'build failed: ixweb-3.10.28.107'
Change 172158 on 2006/04/26 01:05:37 by cm@cm-ixca-cm-build23 'cmbuild: ixweb-3.10.28.106 '
Change 172126 on 2006/04/25 21:41:28 by cm@cm-ixca-cm-build23 'build failed: ixweb-3.10.28.105'
Change 171855 on 2006/04/25 10:10:46 by cm@cm-ixca-cm-build23 'cmbuild: ixweb-3.10.28.103 '
Change 171823 on 2006/04/25 08:54:19 by cm@cm-ixca-cm-build23 'cmbuild: ixweb-3.05.30.5 '
Change 171654 on 2006/04/25 00:09:52 by cm@cm-ixca-cm-build23 'cmbuild: ixweb-3.10.28.102 '
Change 171446 on 2006/04/24 12:30:43 by cm@cm-ixca-cm-build23 'cmbuild: ixweb-3.10.28.101 '
Change 171420 on 2006/04/24 11:13:13 by cm@cm-ixca-cm-build23 'cmbuild: ixweb-3.10.0.1 '
Change 171390 on 2006/04/24 09:45:58 by cm@cm-ixca-cm-build23 'cmbuild: ixweb-3.10.28.100 '
Change 171381 on 2006/04/24 08:29:14 by cm@cm-ixca-cm-build23 'cmbuild: ixweb-3.05.30.4 '
Change 171298 on 2006/04/23 19:07:41 by cm@cm-ixca-cm-build23 'cmbuild: ixweb-3.10.28.99 '
Change 171260 on 2006/04/22 16:40:22 by cm@cm-ixca-cm-build23 'cmbuild: ixweb-3.10.28.98 '
Change 171242 on 2006/04/22 09:12:01 by cm@cm-ixca-cm-build23 'build failed: ixweb-3.10.28.97 '
Change 171241 on 2006/04/22 09:01:52 by cm@cm-ixca-cm-build23 'build failed: ixweb-3.10.28.96 '
Change 171222 on 2006/04/21 21:40:09 by cm@cm-ixca-cm-build23 'build failed: ixweb-3.10.28.95 '
Change 171185 on 2006/04/21 18:25:51 by cm@cm-ixca-cm-build23 'cmbuild: ixweb-3.05.30.3 '
Change 171177 on 2006/04/21 18:04:02 by cm@cm-ixca-cm-build23 'build failed: ixweb-3.05.30.2 '
Change 171160 on 2006/04/21 17:48:17 by cm@cm-ixca-cm-build23 'build failed: ixweb-3.05.30.1 '
Change 171091 on 2006/04/21 15:39:22 by cm@cm-ixca-cm-build23 'build failed: ixweb-3.10.28.94 '
Change 171070 on 2006/04/21 14:58:14 by cm@cm-ixca-cm-build23 'build failed: ixweb-3.10.28.93 '
Change 171033 on 2006/04/21 13:27:23 by cm@cm-ixca-cm-build23 'build failed: ixweb-3.10.28.92 '
Change 171010 on 2006/04/21 12:08:52 by cm@cm-ixca-cm-build23 'cmbuild: ixweb-3.05.0.34 '
Change 170989 on 2006/04/21 11:30:26 by cm@cm-ixca-cm-build23 'build failed: ixweb-3.05.0.33 '
Change 170901 on 2006/04/21 06:43:48 by cm@cm-ixca-cm-build23 'cmbuild: ixweb-3.05.0.32 '
Change 170766 on 2006/04/20 21:28:06 by cm@cm-ixca-cm-build23 'cmbuild: ixweb-3.10.28.91 '
Change 170706 on 2006/04/20 17:23:42 by cm@cm-ixca-cm-build23 'cmbuild: ixweb-3.05.0.31 '
Change 170674 on 2006/04/20 15:55:45 by cm@cm-ixca-cm-build23 'cmbuild: ixweb-3.10.28.90 '
Change 170613 on 2006/04/20 14:12:38 by cm@cm-ixca-cm-build23 'cmbuild: ixweb-3.10.28.89 '
Change 170521 on 2006/04/20 10:45:03 by cm@cm-ixca-cm-build23 'cmbuild: ixweb-3.05.0.30 '
Change 170460 on 2006/04/20 08:53:42 by cm@cm-ixca-cm-build23 'cmbuild: ixweb-3.05.0.29 '
Change 170280 on 2006/04/20 01:46:13 by cm@cm-ixca-cm-build23 'cmbuild: ixweb-3.10.28.88 '

Now I want to extract few data from each line and want to store in one variable.

THE BELOW CODE IS NOT WORKING SOME HOW ... SEEMS LIKE $i IS NOT PASSING EACH LINE & IT IS PASSING BY EACH WORD ...

But for loop is not working here somehow ....
Code:
	for i in `cat /tmp/aa.txt`
		
		do
			
			

			BUILD_DATE=`echo $i | awk '{print $4}'`
			BUILD_TIME=`echo $i | awk '{print $5}'`
			CHANGE_NO=`echo $i | awk '{print $2}'`
						
			BUILD_NO=`echo $i | awk -F"'" '{print $2}' | awk -F":" '{print $2}' | awk -F"-" '{print $2}'`

			
		done

help will be appreciated ...


Thanks a lot
Chirantan
# 2  
Old 04-27-2006
while read i; do
..your code here..
done < /tmp/aa.txt

Cheers
ZB
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with extracting data within parentheses

This is my input file: a|b|c(ef)|g|h(km)|p My output file should look like: a|b|ef|g|km|p That is, pipe is the delimiter. The data within pipe must be displayed as it is but if it encounters any data within parentheses, then only the data within parentheses has to be displayed ( the data... (2 Replies)
Discussion started by: ksatish89
2 Replies

2. UNIX for Dummies Questions & Answers

Extracting data from file

I am trying to compare the data in lines 3 & 5 to see if they match up to the '-S570' (see first code set, all proprietary information has been removed from code set) spawn telnet Trying ... Connected to CA-LOS1234-ASE-S570.cl . Escape character is '^]'. CA-LOS1234-ASE-S570 Username: ... (1 Reply)
Discussion started by: slipshft
1 Replies

3. Shell Programming and Scripting

extracting data

I have a txt file of the following format >ab_ qwerty >rt_ hfjkil >Ty2 hglashglkasghkf; >P2 aklhfklflkkgfgkfl >ui_ vnllkdskkkffkfkkf >we32 vksksjksj;lslsf'sk's's .... ..... I want to split this big file based on the header (>) (5 Replies)
Discussion started by: Lucky Ali
5 Replies

4. Shell Programming and Scripting

Extracting specific lines of data from a file and related lines of data based on a grep value range?

Hi, I have one file, say file 1, that has data like below where 19900107 is the date, 19900107 12 144 129 0.7380047 19900108 12 168 129 0.3149017 19900109 12 192 129 3.2766666E-02 ... (3 Replies)
Discussion started by: Wynner
3 Replies

5. Shell Programming and Scripting

extracting data from a string

Hi there, I have a bunch of vlan tagged network interfaces that are named as follows e1000g111000 e1000g99001 e1000g3456000 nge2002 where the 'e1000g' and 'nge' parts of the name are the driver, the red and blue bits above define the VLAN and the last digit on the end defines the... (3 Replies)
Discussion started by: rethink
3 Replies

6. UNIX for Dummies Questions & Answers

Extracting Data Using SED

Given the following text in a file named extract.txt: listenPort:=25 smtpDestination:=2 enableSSL:= I am trying to extract only the value 2 following smtpDestination:= Someone had suggested I use: sed -e "s/^smtpDestination:=\(.*\)$/\1/" extract.txt but this returns: listenPort:=25 2 ... (2 Replies)
Discussion started by: cleanden
2 Replies

7. Shell Programming and Scripting

extracting data from files..

frnds, I m having prob woth doing some 2-3 task simultaneously... what I want is... I have lots ( lacs ) of files in a dir... I want.. these info from arround 2-3 months files filename convention is - abc20080403sdas.xyz ( for todays files ) I want 1. total no of files for 1 dec... (1 Reply)
Discussion started by: clx
1 Replies

8. Shell Programming and Scripting

extracting integer from data

Hi people, I've encountered a problem. I have a data file like: asd:$123:2 zxc:$456:4 But when I want to extract "$123" and get the number with this command: echo $123 | cut -c 1-10 Im returned with 23 instead of 123. Please help me out, thanks. (4 Replies)
Discussion started by: grotesque
4 Replies

9. Shell Programming and Scripting

extracting a line based on line number

i want to cut all the entries from the /etc/passwd file in which the uid is> 500 for this i was writing this ,m quiet new to all this.. scripting but on the 6th n 8th line ,, i hav to specify a line number .. to get the commnd working .. but i want to use variable i instead of that ,,... (2 Replies)
Discussion started by: narendra.pant
2 Replies

10. Shell Programming and Scripting

Extracting Data From Sendmail

Hello, Like many Unix shops, Our systems send Email alerts whenever things break. I have been tasked with writing a shell script to get the email alerts from Sendmail, extract the Date / Time, From, Subject, and message text from the emails and punch them into a MySQL DB. This will then be... (3 Replies)
Discussion started by: calex
3 Replies
Login or Register to Ask a Question