combine and fill series


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers combine and fill series
# 1  
Old 03-06-2011
combine and fill series

hi all! i have a script with an output like this

abc 123 1246
abc 1386
abc 2589
abc 7383

what can i do if i want to fill the 2nd column with the 2nd string '123'

abc 123 1246
abc 123 1386
abc 123 2589
abc 123 7383

thanks!
# 2  
Old 03-06-2011
Code:
awk '{print $1 FS "123" FS $NF}' file

# 3  
Old 03-06-2011
actually the original file looks like this

abc 123 2345
abc 2478
abc 4684
def 346 4793
def 3578
def 7832
# 4  
Old 03-06-2011
Code:
awk 'NF==3{v=$2}NF==2{$NF=v FS $NF}1' FILE

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

/var getting fill frequently

I have Red hat Linux server. There are 14 NFS shares which are coming from NAS. There are so many messages filling /var/log/messages, which seems like some NFS logging is enables somewhere, but I am not able to figure it out. Every few minutes, it will filll my /var (which is part of root) to 100%... (2 Replies)
Discussion started by: solaris_1977
2 Replies

2. Shell Programming and Scripting

Fill in missing Data

hello everyone, I have a task to input missing data into a file. example of my data below: Wed Feb 01 09:00:02 EST 2012,,,0.4,0.3,,0.3,,0.3,,0.5,,0.3,,,0.4,0.3, Wed Feb 01 09:00:11 EST 2012,,,,,,,0.2,,,,,,,,,, Wed Feb 01 09:00:22 EST... (23 Replies)
Discussion started by: Nolph
23 Replies

3. Shell Programming and Scripting

fill in last column of data

Hello, I am fairly new to awk, and I have the following problem. My file has missing data in the last column, and the program I am pre-processing this file for cannot interpret correctly shortened rows (it just wraps the data around). Is there a way to force awk to create the same... (6 Replies)
Discussion started by: timert34
6 Replies

4. Shell Programming and Scripting

Fill missing values with 2

Hi All, I have 100 .txt files which look like this: 3 4 5 6 7 Now, some files have some numbers missing in them and they look like this: 4 5 6 (6 Replies)
Discussion started by: shoaibjameel123
6 Replies

5. Shell Programming and Scripting

Fill the directory

HI all When i do df -h,it displays the amount of free space. Tell me a command or a script to fill the total space to a certain percent (say 99%) Thanks in advance (8 Replies)
Discussion started by: 2002anand
8 Replies

6. Shell Programming and Scripting

Zero fill a string

How do I zero fill a string. E.g pad a string to two digits m=`date "+%m"` pm=`expr $m - 1` echo $pm the above code echoes 1. I want it to echo 01. Any ideas? (3 Replies)
Discussion started by: timgolding
3 Replies

7. Programming

Zero Fill 10 position field

Hi everyone, I am using shell scripting on a Unix SCO box. It calls a C program named zerofill. I do not know anything about C. I am having an issue with a hash total that should only be zero filled 10 positions but the record has 11 positions. DEBUG RESULTS + nice -n -5 bc -l /tmp/fhash8395... (0 Replies)
Discussion started by: ski
0 Replies

8. UNIX for Dummies Questions & Answers

Fill in columns

Hi, I've got a file with several columns where some entries are missing. Example: a b c d f g h j k l p y r I need to replace the empty spaces with zero, so the new file would be: a b c d f 0 g h j k 0 l p y 0 r The original file is tab delimited. Many thansk for... (3 Replies)
Discussion started by: zajtat
3 Replies

9. Shell Programming and Scripting

fill in missing columns

It can't be that hard, but I just can't figure it out: I have file like: File Sub-brick M_1 S_1 M_2 S_2 M_4 S_4 ... xxx 1 214 731 228 621 132 578 ... and would like to get 0 0 where M_3 S_3 is missing xxx 1 214 731 228 621 0 0 132 578 ... I wrote following script, but can't figure out... (3 Replies)
Discussion started by: avvk
3 Replies

10. Shell Programming and Scripting

Fill the Key fields : Please help us

Hi .... we are having the below file .Column 1, Column 2 ,column 3 are key fields... In the below ...for 2 nd , 3 rd row the repeated key column is missing .... i want the new file to be populated with all missing key columns. ... (11 Replies)
Discussion started by: charandevu
11 Replies
Login or Register to Ask a Question