Need awk script to add a prefix to each line in file

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need awk script to add a prefix to each line in file
# 1  
Old 10-26-2009
Need awk script to add a prefix to each line in file

Hello ,

I have file with below content :


I need an awk script that would add a prefix zero after first ' .



Please help.

Thanks in advance.
# 2  
Old 10-26-2009
One way:

awk -F"\'" '{$2="0"$2}1' OFS="\'" file

# 3  
Old 10-26-2009
Thank you !!It works with nawk on my sys.
# 4  
Old 10-26-2009
code :-

nawk '{$0="0"$0}1' input_file

# 5  
Old 10-26-2009
Originally Posted by ahmad.diab
code :-

nawk '{$0="0"$0}1' input_file


This is not the expected outout:

nawk '{$0="0"$0}1' input_file


# 6  
Old 10-26-2009
sorry guys I miss read the thread , the best solution is Franklin52 solution kindly use it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Add the word "prefix" to beginning of line using sed

SUSE linux bash shell this works test -d /tmpp && echo "directory exists" || echo "directory doesn't exists" |sed -e "s/^/prefix /" prefix directory doesn't exists but why doesn't this work? test -d /tmp && echo "directory exists" || echo "directory doesn't exists" |sed -e... (3 Replies)
Discussion started by: snoman1
3 Replies

2. Shell Programming and Scripting

awk move select fields to match file prefix in two directories

In the awk below I am trying to use the file1 as a match to file2. In file2 the contents of $5,&6,and $7 (always tab-delimited) and are copied to the output under the header Quality metrics. The below executes but the output is empty. I have added comments to help and show my thinking. Thank you... (0 Replies)
Discussion started by: cmccabe
0 Replies

3. Shell Programming and Scripting

Need to add prefix using sed or awk from cat the file

I need the use sed or AWK using cat the file Node1 TDEV RW 1035788 TDEV RW 1035788 Server1 TDEV RW 69053 Server2 TDEV RW 69053 TDEV RW 103579 Server3 TDEV RW 69053 server4 RDF1+TDEV RW 69053 RDF1+TDEV RW 517894 RDF1+TDEV RW 621473 server6 TDEV RW 34526 TDEV RW 34526 (22 Replies)
Discussion started by: ranjancom2000
22 Replies

4. Shell Programming and Scripting

Extract Uniq prefix from a start and end prefix

Dear All, assume i have a file with content: <Start>6000</Start> <Stop>7599</Stop> the output is: 6000 7000 7100 7200 7300 7400 7599 how should we use any awk, sed, perl can do this task, means to extract the uniq prefixes from the start and stop prefix. Thanks Jimmy (3 Replies)
Discussion started by: jimmy_y
3 Replies

5. Shell Programming and Scripting

How to add a line in a file using perl script?

Hi all, I want to search for a line in a file using perl script and add a line above that line.Can any one suggest me command or code to that using script. Thanks BHarath (5 Replies)
Discussion started by: bharathece
5 Replies

6. Shell Programming and Scripting

awk script file command line options

Being new to awk I have a really basic question. It just has to be in the archives but it didn't bite me when I went looking for it. I've written an awk script, placed it in a file, added the "#!/usr/bin/awk -f" at the top of the script and away I go. "% myAwk <inputfile>" gives me exactly what... (2 Replies)
Discussion started by: tomr2k
2 Replies

7. Shell Programming and Scripting

Remove prefix per line in file

Hi, I'm using a .ksh script to split one file into multible files by checking for the prefix per line. It works perfekt (thanks again for anyone involved in helping me with that ;)), but I want to remove the prefix per line too. Means only the line information itself should remain in the... (7 Replies)
Discussion started by: spidermike
7 Replies

8. Shell Programming and Scripting

perl script to add a line into a file

hi all need a perl script to add a line into a file thanks with anticipation (2 Replies)
Discussion started by: karthikn7974
2 Replies

9. Shell Programming and Scripting

script to add first line from another file in aix

Hi All, I want to add a header from one file to another file which is around 2GB in size currently i am using cat to do it. It took more time to process. Is there any way to do it? Please help me .. Thanks in Advance Selva S (4 Replies)
Discussion started by: selvarhce
4 Replies

10. Shell Programming and Scripting

how to extract paragraphs from file in BASH script followed by prefix ! , !! and !!!

I]hi all i am in confusion since last 2 days :( i posted thraed yesterday and some friends did help but still i couldnt get solution to my problem let it be very clear i have a long log file of alkatel switch and i have to seperate the minor major and critical alarms shown by ! , !! and !!!... (6 Replies)
Discussion started by: nabmufti
6 Replies
Login or Register to Ask a Question