Adding a word in front of a word of each line.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Adding a word in front of a word of each line.
# 1  
Old 07-02-2008
Power Adding a word in front of a word of each line.

Adding a word in front of a word of each line.In that line only one word will be there.
pl helpSmilie
# 2  
Old 07-02-2008
Quote:
Originally Posted by Ramesh Vellanki
Adding a word in front of a word of each line.In that line only one word will be there.
pl helpSmilie
Hi,

Assuming the input file as

inp.txt

Code:
hello
shell
scripting

Code:
sed 's/^/UNIX /g' inp.txt

Is this what you expect? If not, please add your sample input and output for your problem

Regards,
Chella
# 3  
Old 07-02-2008
Power Adding a word in front of a word of each line.

Hi,

I dont think it is the one I am seeing for.

Exm:-

I am having a file faulty.txt
in that the lince are given below

12345
abcdef
king

I wanted to add to those line a common word like my name before is ramesh & after is vellanki

it will come like
ramesh12345vellanki
rameshabcdefvellanki
rameshkingvellanki


pl help me
# 4  
Old 07-02-2008
Quote:
Originally Posted by Ramesh Vellanki
Hi,

I dont think it is the one I am seeing for.

Exm:-

I am having a file faulty.txt
in that the lince are given below

12345
abcdef
king

I wanted to add to those line a common word like my name before is ramesh & after is vellanki

it will come like
ramesh12345vellanki
rameshabcdefvellanki
rameshkingvellanki


pl help me

Hi,

Code:
sed 's/^/ramesh/g;s/$/vellanki/g' faulty.txt


Regards,
Chella
This User Gave Thanks to chella For This Post:
# 5  
Old 07-02-2008
Bug Adding a word in front of a word of each line.

Hi,

great it's working.
Thank you very much.



Regards,
Ramesh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find word in a line and output in which line the word occurs / no. of times it occurred

I have a file: file.txt, which contains the following data in it. This is a file, my name is Karl, what is this process, karl is karl junior, file is a test file, file's name is file.txt My name is not Karl, my name is Karl Joey What is your name? Do you know your name and... (3 Replies)
Discussion started by: anuragpgtgerman
3 Replies

2. Shell Programming and Scripting

Read a File line by line and split into array word by word

Hi All, Hope you guys had a wonderful weekend I have a scenario where in which I have to read a file line by line and check for few words before redirecting to a file I have searched the forum but,either those answers dint work (perhaps because of my wrong under standing of how IFS... (6 Replies)
Discussion started by: Kingcobra
6 Replies

3. Shell Programming and Scripting

Fetch entries in front of specific word till next word

Hi all I have following file which I have to edit for research purpose file:///tmp/moz-screenshot.png body, div, table, thead, tbody, tfoot, tr, th, td, p { font-family: "Liberation Sans"; font-size: x-small; } Drug: KRP-104 QD Drug: Placebo Drug: Metformin|Drug:... (15 Replies)
Discussion started by: Priyanka Chopra
15 Replies

4. Shell Programming and Scripting

Script for adding a word in front of all line in a file

Hi I've one file full of paths of certain files and I want to add some extra file words in front of all the paths. for eg: i have a file name test.txt which show some details only.. 024_hd/044/0344eng.txt 035_bv/222/editor.jpg here I want to add /usr/people/indiana/ infront of all the... (4 Replies)
Discussion started by: ratheeshp
4 Replies

5. Shell Programming and Scripting

how to add single digit in front of the word and line in the file.

Hi , how to add the single digit to front of the word and front of the lines in the one file with compare pattern file and get digit. like example pattern file pattern.txt pattern num bala 2 raja 3 muthu 4 File Name: chennai.dat muthu is good boy raja is bad boy selvam in super... (6 Replies)
Discussion started by: krbala1985
6 Replies

6. Shell Programming and Scripting

Print word 1 in line 1 and word 2 in line 2 if it matches a pattern

i have a file in this pattern MATCH1 word1 IMAGE word3 word4 MATCH2 word1 word2 word3 word4 MATCH2 word1 word2 word3 word4 MATCH2 word1 word2 word3 word4 MATCH2 word1 word2 word3 word4 MATCH1 word1 IMAGE word3 word4 MATCH2 word1 word2 word3 word4 MATCH2 word1 word2 word3 word4 MATCH2 word1... (7 Replies)
Discussion started by: bangaram
7 Replies

7. UNIX for Dummies Questions & Answers

regular expression for replacing the fist word with a last word in line

I have a File with the below contents File1 I have no prior experience in unix. I have just started to work in unix. My experience in unix is 0. My Total It exp is 3 yrs. I need to replace the first word in each line with the last word for example unix have no prior experience in... (2 Replies)
Discussion started by: kri_swami
2 Replies

8. Shell Programming and Scripting

Want to add a word in front a of each line of a file

Hi, Can anybody help me how to add a word in front of a line in a file.Actually it is bit tricky to add a word. i will give a sample for this: Input : 1110001 ABC DEF 1110001 EFG HIJ 1110001 KLM NOP 1110002 QRS RST 1110002 UVW XYZ Output: %HD% 1110001 ABC DEF %DT% 1110001 EFG HIJ... (4 Replies)
Discussion started by: apjneeraj
4 Replies

9. Shell Programming and Scripting

adding single word to multiple line.

I have following problem. <File A> contains let say 5 lines but can be changed. cat dog fish car if I want to add word to each line then how do I go about it? I used paste -d but that requires two files having same number of lines but in my case <File A> changes and I just need to... (6 Replies)
Discussion started by: paulds
6 Replies

10. Shell Programming and Scripting

Can a shell script pull the first word (or nth word) off each line of a text file?

Greetings. I am struggling with a shell script to make my life simpler, with a number of practical ways in which it could be used. I want to take a standard text file, and pull the 'n'th word from each line such as the first word from a text file. I'm struggling to see how each line can be... (5 Replies)
Discussion started by: tricky
5 Replies
Login or Register to Ask a Question