Computing.Net > Forums > Unix > Script to change values linebyline

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Script to change values linebyline

Reply to Message Icon

Name: Vini99
Date: February 1, 2009 at 22:17:06 Pacific
OS: AIX
CPU/Ram: RISC
Product: Ibm / Pseries
Subcategory: General
Comment:

Hi,

I’m struggling to write a script to do the following,

-will go through each line in the file
-in a specific character positions, changes
the value to a new value
-These character positions are fixed througout the file

-----------------------
e.g.: file1.sh will have the following 3 lines,

line1 aaaa xxxx
line2 bbbb yyyy
line3 cccc zzzz

After executing the script, content of file1.sh should be,

line1 a1aa xx4x
line2 b1bb yy4y
line3 c1cc zz4z
-----------------------

Guru's, thanks a ton in advance
Vini



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: February 2, 2009 at 07:14:42 Pacific
Reply:
0

Response Number 2
Name: Vini99
Date: February 2, 2009 at 20:52:04 Pacific
Reply:

Hi Nails,

Thanks a lot for the response.
After digging through the net and "sed" man pages came up with the following,
--------------------
sed -e "1n; s/./1/2" -e "s/./4/8" file1.sh > file2.sh
mv file2.sh file1.sh
--------------------

This is giving me the required output & I'm doing some testing on the same.

Thanks Again
Regards
Vini


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Script to change values linebyline

script to change case of extensions www.computing.net/answers/unix/script-to-change-case-of-extensions/5017.html

shell script to get value of field www.computing.net/answers/unix/shell-script-to-get-value-of-field/6716.html

script to change file names www.computing.net/answers/unix/script-to-change-file-names/8327.html