replacement


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers replacement
# 8  
Old 04-29-2011
What do you mean with "and =>420000" ?

---------- Post updated at 06:25 PM ---------- Previous update was at 06:06 PM ----------

Do you mean

"The substring from character 12 to character 17 of the second field is greater than 420000"

????

By respect for people who read you and help you, please make some effort to clarify your explainations, please also take the time to write full words like "because" instead of "bc" or reread the forum rules.

By the way you still didn't provide a representative example that demonstrate the behaviour you expect, or the way you explained it is still not clear enough.

I am willing to help you but i cannot do it in an efficient way from blurred and/or insufficient/unclear information.

If someone reading this thread understand better than me what tjmannonline expects, thanks to put it simply for my limited brain, because so far it looks i just don't get it Smilie
# 9  
Old 05-02-2011
let me rephrase my need:

content looks like this:

2079951061790 SCK0000903092000000000000021300
2079951061790 SCK0000903090000000000000021300

2079951074758 SCK0000420421000000000000092750
2079951074758 SCK0000420401000000000000092750

complet output should look like this:

2079951061790 LCK0000903092000000000000021300
2079951061790 SCK0000903090000000000000021300

2079951074758 LCK0000420421000000000000092750
2079951074758 SCK0000420401000000000000092750

if 2079951061790 exits, and equal or greater then 920000 exists in col48-55, then replaceALL SCK with LCK, else, leave as is.

if 2079951074758 exists, and equal or greater then 420000 exists in col48-55, then replaceALL SCK with LCK, else, leave as is.
# 10  
Old 05-02-2011
90000000 and 420000000 does not start at the same column (so in my example i take from column 25 to 33,but you can adjust those values to your own needs)

Code:
# cat tst
2079951061790 SCK0000903092000000000000021300
2079951061790 SCK0000903090000000000000021300

2079951074758 SCK0000420421000000000000092750
2079951074758 SCK0000420401000000000000092750
# awk '{p=substr($0,25,9)}($1==2079951061790&&p+0>90000000)||($1==2079951074758&&p+0>420000000){sub("SCK","LCK",$0)}1' tst
2079951061790 LCK0000903092000000000000021300
2079951061790 SCK0000903090000000000000021300

2079951074758 LCK0000420421000000000000092750
2079951074758 SCK0000420401000000000000092750
#


Last edited by ctsgnb; 05-02-2011 at 12:53 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Is this MB, which needs replacement ?

Hello, I am getting below error in fmadm output. This server is not in support, so can't reach them. Is it showing that motherboard is faulty and should be replaced ? It was rebooted a week back and then, there were no errors # fmadm faulty --------------- ------------------------------------ ... (1 Reply)
Discussion started by: solaris_1977
1 Replies

2. HP-UX

Terminal replacement

I recently picked up an HP9000 server running HPUX. I would like to replace the CRT terminal console with something I can use a flat panel monitor. Any suggestions would be greatly appreciated. (1 Reply)
Discussion started by: Stevebei
1 Replies

3. Shell Programming and Scripting

help me :replacement

Hi pls help me for below; i have a file .content is : =================== uid,pcsPricingPlan,refPcsQosProfName 821910002022,smartlimit,SGSNQOS1 i have to replace the value of uid and pricingplan by a unix script. may be the value would be next line or any where in the file. pls... (9 Replies)
Discussion started by: Aditya.Gurgaon
9 Replies

4. Shell Programming and Scripting

SED replacement

Hi, i have a file with lines, file.txt ------- test is fun testing is better I need to replace 'test' to 'develop' and i used, a=test b=develop sed "s,$a,$b,g" -------- but i see the word 'testing' is also replaced. Need some solution. Is there any way i could replace only 'test' ? (4 Replies)
Discussion started by: giri_luck
4 Replies

5. Shell Programming and Scripting

String replacement

Hi All, I have below file which has data in below format. #$ | AB_100 | AB_300 ()| AB_4 @*(% | AB-789 i want o/p as below format. | AB_100 | AB_300 | AB_4 | AB-789 So here there is no standard format. How we can achieve the same in unix ? Regards, (3 Replies)
Discussion started by: gander_ss
3 Replies

6. UNIX for Dummies Questions & Answers

Pattern Replacement

There is a requirement that i need to replaced a pattern by another pattern in all the files in my entire file system. there are 1000s of file in the system. let the pattern is "calcuta". i have to replace this pattern by "kolkata" in all those files which contain "calcuta". I am only able to... (12 Replies)
Discussion started by: palash2k
12 Replies

7. UNIX for Advanced & Expert Users

getprotobyname replacement?

I've been tasked with converting our software from strictly an IPv4 environment to handling both IPv4 and IPv6. I'm very nearly done and everything seems to be progressing just fine. There's just one thing that's been nagging me for a while now, so I thought I'd enquire about this. I've read... (1 Reply)
Discussion started by: sszd
1 Replies

8. Shell Programming and Scripting

Need Replacement for sed

Hi Can anyone provide me the replacement of sed with xargs perl syntax for the below sed -e :a -e '/;$/!N;s/\n//; ta' -e 's/;$//' This should be without looping has to take minimal time for search (0 Replies)
Discussion started by: dbsurf
0 Replies

9. Shell Programming and Scripting

Character replacement

Hi, I am working on a command that replaces some occurrences of quotation marks in file. The quotation mark cannot be the first or the last character in line and cannot be preceded or followed by a comma. I am not an expert in regular expressions, but I managed to create the following... (2 Replies)
Discussion started by: piooooter
2 Replies

10. UNIX for Dummies Questions & Answers

Regarding Replacement

I have two files: file1: somedata <html> <head> This is sample statement ...... ...... </head> </html> somedata file2: olga 81 91 B A rene 82 92 B A zack 83 93 Expextd Result: (2 Replies)
Discussion started by: rajx
2 Replies
Login or Register to Ask a Question