adding single word to multiple line.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting adding single word to multiple line.
# 1  
Old 07-25-2008
CPU & Memory 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 add one word to line from <File A> but lines change depend on data.

thanks
# 2  
Old 07-25-2008
Is this a homework question?

What have you tried so far?

Paste your code.
# 3  
Old 07-25-2008
I've used two different files. file1 contain my reports to managers and second file contain our email domain. Unfortunately, not all the time same number of usres receive the file. so file2 contain domain should just be one word ( mycompany.com ) to be attached to file1 that containing links to webserver for their own individual reporsts

paste -d' ' /usr/local/squid/compweb/tmptxt/4div82indi4httplinks.txt /usr/local/squid/compweb/tmptxt/divemail.txt > /usr/local/squid/compweb/
tmptxt/5div82indireport.txt

but above script only works when both files contain same number of lines.

so I just need to add company domainname (i.e: mycompany.com ) to first link which has link and manager email name.

thank you
# 4  
Old 07-25-2008
basically

nawk -F"," '{printf("echo %s | mail -s \"Corporate \- Weekly Internet Usage Report\"\n",$1)}' < /usr/local/squid/websever/tmptxt/3div82reportlinks.txt > /usr/local/squid/webserver/tmptxt/4div82indi4httplinks.txt

will create

echo http://webserverfw:8081/squid-report...doe/index.html | mail -s "Corporate - Weekly Internet Usage Report
" jdoe

so some how I just need to add @mycompany.com at the end of "jdoe" to make it into "jdoe@mycompany.com" so it can fire off email to the managers.


Not sure how to twick above script to add "@mycompany.com" as part of script.
# 5  
Old 07-25-2008
Not exataly what your looking for but might help you...

list.txt:
jim
john
bill
mary

Code:
awk '{ print $1"@some.com"}' list.txt

OUTPUT:
jim@some.com
john@some.com
bill@some.com
mary@some.com
# 6  
Old 07-25-2008
I found the solution.
# 7  
Old 07-25-2008
MySQL

Quote:
Originally Posted by Ikon
Not exataly what your looking for but might help you...

list.txt:
jim
john
bill
mary

Code:
awk '{ print $1"@some.com"}' list.txt

OUTPUT:
jim@some.com
john@some.com
bill@some.com
mary@some.com
thank you!! that is the EXACTLY same method I stumbled upon! so it validates Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Get count of multiple word in single command

Hello Experts, I have a log file that contains 4 different type of exception : 1- Exception 2- Fatal 3- Error 4- Exec My requirement is to find count of each type of exception, i tried using combination of -E and -C but that doesn't seems to be working : grep -ec 'Exception' -ec... (4 Replies)
Discussion started by: mukulverma2408
4 Replies

2. Shell Programming and Scripting

sed command to grep multiple pattern present in single line and delete that line

here is what i want to achieve.. i have a file with below contents cat fileName blah blah blah . .DROP this REJECT that . --sport 7800 -j REJECT --reject-with icmp-port-unreachable --dport 7800 -j REJECT --reject-with icmp-port-unreachable . . . more blah blah blah --dport 3306... (14 Replies)
Discussion started by: vivek d r
14 Replies

3. Shell Programming and Scripting

convert single line output to multiple line

Hi all, I have a single line output like below echo $ips 10.26.208.28 10.26.208.26 10.26.208.27 want to convert above single line output as below format. Pls advice how to do ? 10.26.208.28 10.26.208.26 10.26.208.27 Regards Kannan (6 Replies)
Discussion started by: kamauv234
6 Replies

4. Shell Programming and Scripting

word counts for a single line xml file

I have any XML ouput file(file name TABLE.xml), where the data is loaded in A SINGLE LINE, I need help in writting a ksh shell script which gives me the word counts of word <TABLE-ROW> This is my input file. <?xml version="1.0" encoding="UTF-8"?><!--Generated by Ascential Software... (4 Replies)
Discussion started by: pred55
4 Replies

5. Shell Programming and Scripting

Multiple lines in a single column to be merged as a single line for a record

Hi, I have a requirement with, No~Dt~Notes 1~2011/08/1~"aaa bbb ccc ddd eee fff ggg hhh" Single column alone got splitted into multiple lines. I require the output as No~Dt~Notes 1~2011/08/1~"aaa<>bbb<>ccc<>ddd<>eee<>fff<>ggg<>hhh" mean to say those new lines to be... (1 Reply)
Discussion started by: Bhuvaneswari
1 Replies

6. 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

7. 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

8. Shell Programming and Scripting

Looking for a single line to count how many times one character occurs in a word...

I've been looking on the internet, and haven't found anything simple enough to use in my code. All I want to do is count how many times "-" occurs in a string of characters (as a package name). It seems it should be very simple, and shouldn't require more than one line to accomplish. And this is... (2 Replies)
Discussion started by: Shingoshi
2 Replies

9. Shell Programming and Scripting

single line input to multiple line output with sed

hey gents, I'm working on something that will use snmpwalk to query the devices on my network and retreive the device name, device IP, device model and device serial. I'm using Nmap for the enumeration and sed to clean up the results for use by snmpwalk. Once i get all the data organized I'm... (8 Replies)
Discussion started by: mitch
8 Replies

10. Shell Programming and Scripting

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 help:( (4 Replies)
Discussion started by: Ramesh Vellanki
4 Replies
Login or Register to Ask a Question