Sponsored Content
Full Discussion: Replace specific columns
Top Forums Shell Programming and Scripting Replace specific columns Post 302246281 by jisha on Monday 13th of October 2008 08:22:42 AM
Old 10-13-2008
Replace specific columns

hi All,

Thi sis very urgent.

I have large files with pipe delimited.
For example:
1.txt
1001024|120|9|-0.0|#|
1001025|120|9|#|
1001026|120|9|#|
1001032|120|2|-0.0|#|
1002026|110|9|#|
1002027|110|9|-0.0|#|
1002028|120|1|1.0|#|

I need to replace the 4th filed if it is # by |-|
my final txt file should like like below;

2.txt (out put)
1001024|120|9|-0.0|#|
1001025|120|9|-|
1001026|120|9|-|
1001032|120|2|-0.0|#|
1002026|110|9|-|
1002027|110|9|-0.0|#|
1002028|120|1|1.0|#|

Please help
Thanks in advance
JS
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Replace columns from File1 with columns from File2

Hi all, I would like to replace some columns from file1 with columns from file2. Currently, I'm able to do it with the following command: awk 'NR==FNR{a=$1;b=$2;c=$3;next;} {$2=a;$4=b;$5=c;print}' file2 file1 > temp mv -f temp file1 First, i make the changes and save it as a temp... (1 Reply)
Discussion started by: seijihiko
1 Replies

2. Shell Programming and Scripting

using sed to replace a specific string on a specific line number using variables

using sed to replace a specific string on a specific line number using variables this is where i am at grep -v WARNING output | grep -v spawn | grep -v Passphrase | grep -v Authentication | grep -v '/sbin/tfadmin netguard -C'| grep -v 'NETWORK>' >> output.clean grep -n Destination... (2 Replies)
Discussion started by: todd.cutting
2 Replies

3. Shell Programming and Scripting

Using sed to replace specific character and specific position

I am trying to use sed to replace specific characters at a specific position in the file with a different value... can this be done? Example: File: A0199999123 A0199999124 A0199999125 Need to replace 99999 in positions 3-7 with 88888. Any help is appreciated. (5 Replies)
Discussion started by: programmer22
5 Replies

4. Shell Programming and Scripting

Find and replace a string a specific value in specific location in AIX

Hi, I have following samp.txt file in unix. samp.txt 01Roy2D3M000000 02Rad2D3M222222 . . . . 10Mik0A2M343443 Desired Output 01Roy2A3M000000 02Rad2A3M222222 . . (5 Replies)
Discussion started by: techmoris
5 Replies

5. Shell Programming and Scripting

Replace specific columns in one file with columns in another file

HELLO! This is my first post here! By the way, I think it is great that people do this. My question: I have two files, one is a .dilm and one is a .txt. It is my understanding that the .dilm file can be treated as a .txt file. I wrote another program where I was able to manipulate it as if it... (3 Replies)
Discussion started by: mehdib
3 Replies

6. UNIX for Dummies Questions & Answers

replace "," with "." only in specific columns of a file?

Hi all, I have this text file containing 9 columns separated by space. The 8th columns contains the numbers. C1 C2 C3 C4 C5 C6 C7 C8 C9 er rt yt gh iu nk il 0.07 xs yt lr ty bg iu zk nh 0,0005 lt ...etc. I want to replace the comma with full stop only in 8th coloumn. the output... (8 Replies)
Discussion started by: Unilearn
8 Replies

7. Shell Programming and Scripting

Replace specific field on specific line sed or awk

I'm trying to update a text file via sed/awk, after a lot of searching I still can't find a code snippet that I can get to work. Brief overview: I have user input a line to a variable, I then find a specific value in this line 10th field in this case. After asking for new input and doing some... (14 Replies)
Discussion started by: crownedzero
14 Replies

8. Shell Programming and Scripting

Can't figure out how to find specific characters in specific columns

I am trying to find a specific set of characters in a long file. I only want to find the characters in column 265 for 4 bytes. Is there a search for that? I tried cut but couldn't get it to work. Ex. I want to find '9999' in column 265 for 4 bytes. If it is in there, I want it to print... (12 Replies)
Discussion started by: Drenhead
12 Replies

9. UNIX for Dummies Questions & Answers

Printing lines with specific strings at specific columns

Hi I have a file which is tab-delimited. Now, I'd like to print the lines which have "chr6" string in both first and second columns. Could anybody help? (3 Replies)
Discussion started by: a_bahreini
3 Replies

10. Shell Programming and Scripting

Search and replace specific positions of specific lines

Hi, I have a file with hundreds of lines. I want to search for particular lines starting with 4000, search and replace the 137-139 position characters; which will be '000', with '036'. Can all of this be done without opening a temp file and then moving that temp file to the original file name. ... (7 Replies)
Discussion started by: dsid
7 Replies
ogamesim(6)							   Games Manual 						       ogamesim(6)

NAME
Console Ogame Simulator SYNOPSYS
ogamesim [ -i <task.txt> ] [ -o <result.txt> ] DESCRIPTION
Tasks for simulation are consist of text files. Example of task concluding all possible units is adduced bellow. OPTIONS
-i <input file>: task file (STDIN unless defined); -o <output file>: result file (STDOUT unless defined); -s <iterations count>: 1 <= value <= N (no limits); -t <max simulation time>: (seconds) 0 <= value <= N, 0=no limits; -f <forks count>: 0 <= value <= 100. RETURN VALUES
0: if success EXAMPLES
Task concluding all possible units: attacker attack = 9 shield = 10 armory = 11 Small Cargo = 10 Large Cargo = 10 Light Fighter = 20 Heavy Fighter = 30 Cruiser = 40 Battleship = 50 Colony Ship = 60 Recycler = 70 Espionage Probe = 80 Bomber = 900 Destroyer = 110 Deathstar = 120 defender attack = 11 shield = 12 armory = 13 Rocket Launcher = 100 Light Laser = 200 Heavy Laser = 300 Gauss Cannon = 400 Ion Cannon = 500 Plasma Turret = 600 Small Shield Dome = 1 Large Shield Dome = 1 Solar Satellite = 100 metal = 123456 crystal = 56789 deut = 987654 ogamesim Dec 4, 2006 ogamesim(6)
All times are GMT -4. The time now is 12:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy