Searching using awk - Help required

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Searching using awk - Help required
# 1  
Old 10-19-2009
Java Searching using awk - Help required


I am working on script to search some records in a file based on certain fields and each record is a ASCII fixed size. I was using awk to search based on certain condition. But the length of the record is too much that awk is giving

syntax error near unexpected token `('

Request urgent help on this or any other idea.
# 2  
Old 10-19-2009
kindly post some input , desired output and the code you have written
# 3  
Old 10-19-2009

Hi This is my input

9002000000000000026203267021886820090909135733000000000000000091000000491777955457000000000000000000000000D4177001000000000000000000000000D41763E301954559751073741828                                                                                           0000000000000000000000000000A9FFA0F00000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000                    0096798136000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000  059000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000195455975000000000000000000000000D41763E302001000000000000000000000000000000000000000000000000000000000A9FFA0F0000000019920000000047478802939697E9740000002009090913573320090909140139000000000001000000000001000000000246000000000000000001300

for example:

awk '{if((substr($0,1,2)=="90")) print $0}'  is the code

Last edited by Franklin52; 10-19-2009 at 08:11 AM.. Reason: Please use code tags!!
# 4  
Old 10-19-2009
that works fine. show how you actually run your script.
# 5  
Old 10-19-2009
Dont copy paste the input, the input i pasted in previous post should be taken as a single line. Then you will get that error.
# 6  
Old 10-19-2009
awk 'substr($0,1,2)==90' in_file

awk '/^90/' in_file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Searching value in table through awk

I need to create one script in which I want to search in txt file , this txt file is having 10 columns , I want to check 4th column value if "BOY" & 10th column value =>500 it will print 4th column row value ,1st column row value & 10th column row value & store the same value in one file as... (2 Replies)
Discussion started by: dravi_laxmi
2 Replies

2. Shell Programming and Scripting

Help required in searching of pattern.

i m searching a zone file my domain name is my zone file looks like this. IN SOA ( 400 IN A Then i am searching that have if below ip... (14 Replies)
Discussion started by: learnbash
14 Replies

3. Shell Programming and Scripting

Searching and printing only required pattern

Hi all, i am trying to count the number of logical processors from the below output: # print_manifest | grep "logical processors" 8 cores, 16 logical processors per socket 2 logical processors (2 per socket) i just want to have below output : 16 2 also... (11 Replies)
Discussion started by: omkar.jadhav
11 Replies

4. Shell Programming and Scripting

awk help required

Hello, I am trying to get an output from awk and have been unsuccessful so far. There is an input file which contains certain segments, that needs to be read and append with another data after matching the segment... Input file is as shown below ISA*00* *00* *01*781495650... (2 Replies)
Discussion started by: rakeshv
2 Replies

5. Shell Programming and Scripting

searching the required string and appending string to it.

Hi all, I have some data in the form of adc|nvhs|nahssn|njadnk|nkfds in the above data i need to write a script so thet it will append "|||" to the third occurnace in the string ..... the outout should look like adc|nvhs|nahssn||||njadnk|nkfds Thanks, Firestar. (6 Replies)
Discussion started by: firestar
6 Replies

6. Shell Programming and Scripting

awk searching

hi all, Please can you help me with the awk searching where: I have a master file where I need the string $12. the string $ 12 varies between 3 and 4 characters and I need to bring only the characters ending in 68. try this, but is so bad my search i know awk-F, '(if... (8 Replies)
Discussion started by: manzi
8 Replies

7. Shell Programming and Scripting

Awk help required

Hi All, I have 2 .csv files as below File1.csv name1,20,30,date1 name2,30,40,date1 File2.csv name1,25,35,date1 name2,45,55,date1 Can any one help me to add the 2nd and 3rd column of file1 and file2 and write the output into a new file as below name1,45,65,date1... (9 Replies)
Discussion started by: ajay547
9 Replies

8. Shell Programming and Scripting

awk and searching within a block ?

Hi, I wonder if anybody could help. How do i awk out (or indeed using another utility) a particular value that exists within a defined block, for example if i have a file that looks like the one below and i want to get at the "Product Serial" for the block referring to "mb.fru" (bolded and coloured... (4 Replies)
Discussion started by: rethink
4 Replies

9. Shell Programming and Scripting

Help required on awk

Hi, I have a fixed with file, which have almost 10 records Sample File: ------------ AR 100 TTT BC 200 SSS DA 199 YYY AR 500 RRR PO 300 QQQ PB 800 PPP PC 150 OOO AR 111 CCC AD 321 LLL I Have to check for first two charactors and if its 'AR' i have to save those records to one... (3 Replies)
Discussion started by: meetavin
3 Replies

10. Shell Programming and Scripting

awk searching between two files

hi there, im writing some script in awk; in few words i have a list from router (mac address- ip address) and the second list with only the mac addresses. the thing is that i want search list from router for the first mac address; if found - print the ip address, if not print error; then search... (1 Reply)
Discussion started by: mac7
1 Replies
Login or Register to Ask a Question