Find Word within ^A delimiter


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find Word within ^A delimiter
# 1  
Old 04-23-2011
Question Find Word within ^A delimiter

I have a file in which the following pattern is there
TAG001^A<value>^A

I want to find all such values(words) which comes right next to "TAG001^A" and before the next "^A".

^A is the delimiter here.

Please help!

Note: I think ^A in unix resolves to \001 as delimiter

Last edited by royzlife; 04-23-2011 at 03:13 PM..
# 2  
Old 04-23-2011
Does the value come in "<" and ">"?
regards,
Ahamed

---------- Post updated at 11:07 AM ---------- Previous update was at 11:05 AM ----------

try this

Code:
echo "TAG001^A<value>^A" | awk -F'\\^A' '{print $2}'

Code:
awk -F'\\^A' /TAG001/ '{print $2}' file

regards,
Ahamed

Last edited by ahamed101; 04-23-2011 at 05:32 PM..
# 3  
Old 04-23-2011
Code:
awk -F"\x01" '$1=="TAG001"{print $2}' file

# 4  
Old 04-24-2011
Code:
echo "TAG001^A<value>^A" | awk -F"<|>" '{print $2}'

# 5  
Old 04-24-2011
I think the question should be re-modified -

in a file we have the following lines -
xxxx^Ayyyy^Azzzz^ATAG001^A12345^ATAG002........
qqqq^Awwww^Aeeee^ATAG001^A56789^ATAG002........

The position of TAG001 is not fixed but per line there is only 1 TAG001.

I need to retrieve the values 12345,56789 which lies within TAG001^A and the next ^A.

I hope the problem is clear than before.

Thanks every one!
# 6  
Old 04-24-2011
Code:
awk -F"\x01" '{for(i=1;i<NF;i++) if($i=="TAG001")print $(i+1)}' file

# 7  
Old 04-24-2011
Code:
$ awk -F'TAG001\\^A|\\^A' '{print $5}' test_file 
12345
56789

$ cat test_file 
xxxx^Ayyyy^Azzzz^ATAG001^A12345^ATAG002........
qqqq^Awwww^Aeeee^ATAG001^A56789^ATAG002........

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find a word and increment the number in the word & save into new files

Hi All, I am looking for a perl/awk/sed command to auto-increment the numbers line in file, P1.tcl: run_build_model sparc_ifu_dec run_drc set_faults -model path_delay -atpg_effectiveness -fault_coverage add_delay_paths P1 set_atpg -abort_limit 1000 run_atpg -ndetects 1000 I would like... (6 Replies)
Discussion started by: jypark22
6 Replies

2. Shell Programming and Scripting

Find word in a line and output in which line the word occurs / no. of times it occurred

I have a file: file.txt, which contains the following data in it. This is a file, my name is Karl, what is this process, karl is karl junior, file is a test file, file's name is file.txt My name is not Karl, my name is Karl Joey What is your name? Do you know your name and... (3 Replies)
Discussion started by: anuragpgtgerman
3 Replies

3. Shell Programming and Scripting

Shell Script @ Find a key word and If the key word matches then replace next 7 lines only

Hi All, I have a XML file which is looks like as below. <<please see the attachment >> <?xml version="1.0" encoding="UTF-8"?> <esites> <esite> <name>XXX.com</name> <storeId>10001</storeId> <module> ... (4 Replies)
Discussion started by: Rajeev_hbk
4 Replies

4. Shell Programming and Scripting

perl lwp find word and print next word :)

hi all, I'm new there, I'm just playing with perl and lwp and I just successfully created a script for log in to a web site with post. I have a response but I would like to have something like this: I have in my response lines like: <div class="sender">mimi020</div> <some html code.....>... (3 Replies)
Discussion started by: vogueestylee
3 Replies

5. UNIX for Dummies Questions & Answers

Find EXACT word in files, just the word: no prefix, no suffix, no 'similar', just the word

I have a file that has the words I want to find in other files (but lets say I just want to find my words in a single file). Those words are IDs, so if my word is ZZZ4, outputs like aaZZZ4, ZZZ4bb, aaZZZ4bb, ZZ4, ZZZ, ZyZ4, ZZZ4.8 (or anything like that) WON'T BE USEFUL. I need the whole word... (6 Replies)
Discussion started by: chicchan
6 Replies

6. Shell Programming and Scripting

Find and replace a word in all the files (that contain the word) under a directory

Hi Everyone, I am looking for a simple way for replacing all the files under a directory that use the server "xsgd1234dap" with "xsdr3423pap". For Example: In the Directory, $pwd /home/nick $ grep -l "xsgd1234dap" *.sh | wc -l 119 I have "119" files that are still using... (5 Replies)
Discussion started by: filter
5 Replies

7. UNIX for Advanced & Expert Users

use a word as a delimiter with cut

Is there a way to use a word as a delimiter with cut? Or is there a way to use sed or awk with a word as a delimiter? I don't care which program I use for a delimiter I just want to use a word as a delimiter. (2 Replies)
Discussion started by: cokedude
2 Replies

8. Shell Programming and Scripting

How to find the Delimiter?

Hi All, Is there any method we can use to find what is the delimiter used in a text file, asuming the files has fixed number of colomns. Thanks in advance. Js (9 Replies)
Discussion started by: jisha
9 Replies

9. Shell Programming and Scripting

How to find last delimiter in line?

I am working in a ksh script. I am reading a login, password, and database name from a pre-existing config file. Login and password are simple, I take the value after the first "=" sign, but the dbname has multiple equal signs in it. I have it working by temporarily reading the 23rd field, but... (4 Replies)
Discussion started by: prismtx
4 Replies

10. Shell Programming and Scripting

find a word in a file, and change a word beneath it ??

Hi all, I have a file with lines written somewhat like this. aaaa ccc aa linux browse = no xssxw cdcedc dcsdcd csdw police dwed dwd browse = no cdecec (2 Replies)
Discussion started by: vikas027
2 Replies
Login or Register to Ask a Question