To find a character immediately following a word


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To find a character immediately following a word
# 1  
Old 07-11-2008
To find a character immediately following a word

Hello,

I have data in one file like -

UNB+UNOA:1+006415160:1+WF0000010188:ZZ+080701:0600+2++DELFOR++++T'UNH+2+DELFORSmilie:97A:UN................

Now, I want to find what is the character immediately following UNB(here +) UNOA (here Smilie or the character immedialtely preceding UNH (here ') & want to store them in different variables.

Please help me on how to do it.
# 2  
Old 07-11-2008
Code:
#  sed 's/.*UNB\(.\).*/\1/' infile
+


#  sed 's/.*\(.\)UNH.*/\1/' infile
'

etc...

HTH
# 3  
Old 07-11-2008
I did not get ur solution, Tytalus.

'sed' is used for replacinone str with another. I want to find the first occurance of UNB, UNH or UNOA and store the corresponding characters in different variables. I will use those variables later in the script.

Please guide.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find directory immediately after the pattern dir name

Hi, From below directories path I need the directory which comes immediately after the "DataPath" /var/errors/LogDefaultPath/DataPath/Data01/Data02 (Directory name "Data01" is the result from this path) /var/errors/LogDefaultPath/DataPath/Log01/Log0202 (Directory name "Log01" is the... (4 Replies)
Discussion started by: Yuvaan12
4 Replies

2. 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

3. Shell Programming and Scripting

Find character and Replace character for given position

Hi, i want find the character '-' in a file from position 284-298, if it occurs i need to replace it with 'O ' for the position in the file. How to do that using SED command. thanks in advance, Sara (9 Replies)
Discussion started by: Sara183
9 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. Shell Programming and Scripting

Delete character from a word

Friends, I'm looking for a command that delete the first tho caractere in a word. Here is an exp : I want to replace "20091001" by "091001" or "replace" by "place" Thx, (13 Replies)
Discussion started by: newpromo
13 Replies

8. Shell Programming and Scripting

Command to parse a word character by character

Hi All, Can anyone help me please, I have a word like below. 6,76 I want to read this word and check if it has "," (comma) and if yes then i want to replace it with "." (dot). That means i want to be changed to 6.76 If the word doesnot contain "," then its should not be changed. Eg. ... (6 Replies)
Discussion started by: girish.raos
6 Replies

9. Shell Programming and Scripting

To find a character immediately following a specified String

Hello, I have a UNIX file in which data is like this -- ISA*00* *00* *01*006415160 *01*137361242 ... (3 Replies)
Discussion started by: The Observer
3 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