try this script:

for i in 'find required files';
do
awk '{if($1=="set" && $2=="abc" && $3=="1") {print $1,$2,"0"} else {print
$0}}' $i
done;

i haven't tried it - I am not that good at shell scripting
Pipes are what i like - this loop is from my mentor.
If i get a piped workout - will let you know ;)

On Fri, Nov 7, 2008 at 18:49, Phani Bhushan Tholeti <[EMAIL PROTECTED]>wrote:

> use awk - its very powerful and simple to use.
> fo reg, in the last case replacing
> "set abc 1" with "set abc 0"
> just do this:
> awk '{if($1=="set" && $2=="abc" && $3=="1") {print $1,$2,"0"} else {print
> $0}}' <files>
> if you have only one file
>
> If you have many files, go for awk scripting - you can then redirect your
> output more easily.
>
> You can go thru the attachment too, for better idea ;)
>
>
> On Fri, Nov 7, 2008 at 17:37, sainath reddy .k <[EMAIL PROTECTED]>wrote:
>
>>
>>
>> In the man pages of tail, it says "-n" option outputs last N lines...i
>> didnt find the option of giving +2/-2 sort of thing.  I think the
>> switch "-n" accepts an integer, how does it work?
>>
>> B/w I need a similar help, In a file I have a line something like "set
>> abc 1", i want to replace this line with "set abc 0".
>> I have some 100's of files like this i want to replace all such
>> occurrences, irrespective of what the line number is.
>>
>> Thanks,
>> sainath
>>
>> On Nov 7, 10:59 am, "narendra sisodiya" <[EMAIL PROTECTED]>
>> wrote:
>> > $ tail -n+2 file1.txt
>> >
>> > this will print full file ,, except first line,,,
>> > so,, redirect to new file
>> >
>> > $ tail -n+2 file1.txt > file1.txt.new
>> >
>> > or better first move file
>> >
>> > $ mv file1.txt file1.txt.old
>> > $ tail -n+2 file1.txt.old > file1.txt
>> >>
>>
>
>
> --
> Lots o' Luv,
> Phani Bhushan
>
> Let not your sense of morals prevent you from doing what is right - Isaac
> Asimov (Salvor Hardin in Foundation and Empire)
>



-- 
Lots o' Luv,
Phani Bhushan

Let not your sense of morals prevent you from doing what is right - Isaac
Asimov (Salvor Hardin in Foundation and Empire)

--~--~---------~--~----~------------~-------~--~----~
[EMAIL PROTECTED] mailing list -- group http://groups.google.com/group/iitdlug
-~----------~----~----~----~------~----~------~--~---

Reply via email to