execution problem

Hi

i have a file in which there are three fields

code:

919804199233 404911130003916 357266044991350F

and now i want to add two more fields i.e.

code:

919804199233 404911130003916 357266044991350F ms 123

how can i do it using command line

and if have a file of 100 lines and i want to add same field in every line

what will be the code?

Click the URL to see how!

sed 's/$/ ms 123/g' input

Use sed -i for in-file editing.

Answer for 2nd query "and if have a file of 100 lines and i want to add same field in every line "

Answer :: I have created a file "data1.txt" with the below data

$ cat  > data1.txt
1 2 3
4 5 6
 

To add "NEW TEXT " in all lines of "data1.txt"

Output for this AWK

 
$ awk  -F=" " ' { print $1,$2,$3,"NEW TEXT" } ' data1.txt
1 2 3  NEW TEXT
4 5  6 NEW TEXT

@adirajup
Wouldn't this suffice: awk '{print $0,"NEW TEXT"}' data1.txt

Yes this is a good AWK lcode

Hi

Thanks all for your response.

Kindly also let me know what is the code if want to add in starting of some field

for example :

i have a number 9868753007

and i want to add +91 at starting of this number i.e. +919868753007

what will be the code...

Kindly give ur valiable suggestions

Where is this "execution problem" you submitted? (Subject of your thread...)

[quote=esumiba;302591708]
Hi

for example :

i have a number 9868753007

and i want to add +91 at starting of this number i.e. +919868753007

My reply

 
create a file
 
cat > jan20-2
9868753007
9241202145
9524565983
 
Use AWK to insert +91 before the 
 
awk -F" " '{ i = "+91" } { print i$1 }' jan20-2
+919868753007
+919241202145
+919524565983
 

---------- Post updated at 01:12 AM ---------- Previous update was at 01:04 AM ----------

for Inserting +91 to 9868753007 in afile

i have a file with data

9868753007
9248989865
9784589899

 
$ awk -F" " '{ i = "+91" } { print i$1 }' file2
 
output in the file
 
cat file2
 
+919868753007
+919248989865
+919784589899
 
 
 
 
$ cat > file2
9868753007
9248989865
9784589899
$
$ sed -i 's/^/+91/' file2
$
$ cat file2
+919868753007
+919248989865
+919784589899