Sponsored Content
Top Forums Shell Programming and Scripting Find and replace using sed command Post 302771405 by kmanivan82 on Wednesday 20th of February 2013 02:37:26 PM
Old 02-20-2013
Find and replace using sed command

The content of the file filea.txt is as follows.
---------
Code:
case $HOSTNAME in
        aaa)
                DS_PARM_VALUE_SET=vsDev
                APT_Configuration_File=/appl/infoserver/Server/Configurations/2node.apt

                ;;
        bbb)
                DS_PARM_VALUE_SET=vsQA
                APT_Configuration_File=/appl/infoserver/Server/Configurations/2node.apt

                ;;
        ccc)
                DS_PARM_VALUE_SET=vsProd
                APT_Configuration_File=/appl/infoserver/Server/Configurations/2node.apt

                ;;
        *)
                DS_PARM_VALUE_SET=vsDev
                APT_Configurations_File=/appl/infoserver/Server/Configuarations/2node.apt

                ;;
esac

---------

Now aaa has to be changed to 'DEV', bbb has to be changed to 'QA' and ccc has to be changed to 'PROD'.

The new file should be as follows.
---------
Code:
case $HOSTNAME in
        'DEV')
                DS_PARM_VALUE_SET=vsDev
                APT_Configuration_File=/appl/infoserver/Server/Configurations/2node.apt

                ;;
        'QA')
                DS_PARM_VALUE_SET=vsQA
                APT_Configuration_File=/appl/infoserver/Server/Configurations/2node.apt

                ;;
        'PROD')
                DS_PARM_VALUE_SET=vsProd
                APT_Configuration_File=/appl/infoserver/Server/Configurations/2node.apt

                ;;
        *)
                DS_PARM_VALUE_SET=vsDev
                APT_Configurations_File=/appl/infoserver/Server/Configuarations/2node.apt

                ;;
esac

---------
I have tried the following command to perform this. But it did not work.

---------
Code:
find ${Appl_Path} -type f -name '*.properties' -print | while read i
do
    sed -e 's/aaa/\'DEV\'/g' $i > $i.tmp && mv $i.tmp $i
    sed -e 's/bbb/\'QA\'/g' $i > $i.tmp && mv $i.tmp $i
    sed -e 's/ccc/\'PROD\'/g' $i > $i.tmp && mv $i.tmp $i
done

---------


Can anyone help me to fix this issue?

Thanks
Krishnakanth Manivannan

Last edited by Franklin52; 02-21-2013 at 03:27 AM.. Reason: Please use code tags for data and code samples
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to use sed or perl command to find and replace a directory in a file

how to use sed command to find and replace a directory i have a file.. which contains lot of paths ... for eg.. file contains.. /usr/kk/rr/12345/1 /usr/kk/rr/12345/2 /usr/kk/rr/12345/3 /usr/kk/rr/12345/4 /usr/kk/rr/12345/5 /usr/kk/rr/12345/6 /usr/kk/rr/12345/7... (1 Reply)
Discussion started by: wip_vasikaran
1 Replies

2. Shell Programming and Scripting

Sed command to find, manipulate and replace a number

Hi, Im very new to the world of sed so I'm really not even sure if this is possible. What i need to do is read from a flat file and every time i see this line: VAL=123,456 I need to change 456 to 457 for every occurence of this line in the file. The numbers 123 and 456 are different for... (6 Replies)
Discussion started by: LT_2008
6 Replies

3. Shell Programming and Scripting

Loop with sed command to replace line with sed command in it

Okay, title is kind of confusion, but basically, I have a lot of scripts on a server that I need to replace a ps command, however, the new ps command I'm trying to replace the current one with pipes to sed at one point. So now I am attempting to create another script that replaces that line. ... (1 Reply)
Discussion started by: cbo0485
1 Replies

4. Shell Programming and Scripting

find and replace with sed

Hi, I have two files file1 :> val="10" port="localhost:8080" httpadd="http:\\192.168.0.239" file2 :> val=${val} port=${port} httpadd=${httpadd} fileloc=${fileloc} file3(or file2) should have following output(input from fileone) file3 (8 Replies)
Discussion started by: nitin.pathak
8 Replies

5. Shell Programming and Scripting

find and replace using SED

I need to do a find and replace. I tried below logic but getting warnings Could you please help? a=`echo "<!DOCTYPE aaaaa bbbbb \"sample.dtd\">"` b="<!DOCTYPE aaaaa bbbbb \" /a/b/c/datain/d_k/sample.dtd \">" echo $a | sed -e "s/$a/$b/" > c.txt getting the following error sed:... (1 Reply)
Discussion started by: kmanivan82
1 Replies

6. Shell Programming and Scripting

sed command to find and replace

Hello All, I need a sed command to find and replace below text in multiple files in a directory. Original Text :- "$SCRIPT_PATH/files" Replace with :- "$RESOURCE_FILE" Thank you in advance !!! Regards, Anand Shah (1 Reply)
Discussion started by: anand.shah
1 Replies

7. Shell Programming and Scripting

sed find and replace command not working

Hi, Am trying to replace a character '-' with 'O' in position 289 in my file but am not success with below command. sed 's/^\(.\{289\}\)-/\1O/' filename sed: 0602-404 Function s/^\(.\{289\}\)-/\1O/ cannot be parsed. Thanks in Advance Sara Video tutorial on how to use code tags in The... (9 Replies)
Discussion started by: Sara183
9 Replies

8. Shell Programming and Scripting

sed command to skip the first line during find and replace operation

Hi Gurus, I did an exhaustive search for finding the script using "sed" to exclude the first line of file during find and replace. The first line in my file is the header names. Thanks for your help.. (4 Replies)
Discussion started by: ks_reddy
4 Replies

9. Shell Programming and Scripting

Find and replace using sed

File 1,2,33,C,B 3,5,66,K,R 1,2,33,H,M 3,5,66,M,C 6,9,66,J,F I will use the below command to find and replace in sed, where I'm using variable to find pattern. while read line do sed 's/$line/77/' file done<inputfile But here I need to find value in column 3 and... (26 Replies)
Discussion started by: Roozo
26 Replies

10. Shell Programming and Scripting

Help with Passing the Output of grep to sed command - to find and replace a string in a file.

I have a file example.txt as follows :SomeTextGoesHere $$TODAY_DT=20140818 $$TODAY_DT=20140818 $$TODAY_DT=20140818I need to automatically update the date (20140818) in the above file, by getting the new date as argument, using a shell script. (It would even be better if I could pass... (5 Replies)
Discussion started by: SriRamKrish
5 Replies
ppmtosixel(1)						      General Commands Manual						     ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 01:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy