The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
make multiple line containing a pattern into single line VTAWKVT Shell Programming and Scripting 13 12-04-2008 06:40 PM
single line input to multiple line output with sed mitch Shell Programming and Scripting 8 07-16-2008 02:57 PM
Adding a word in front of a word of each line. Ramesh Vellanki Shell Programming and Scripting 4 07-02-2008 10:17 AM
replacing multiple lines with single line siba.s.nayak Shell Programming and Scripting 3 05-28-2008 03:43 AM
Splitting a single line into multiple lines thanuman Shell Programming and Scripting 4 02-23-2005 04:56 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-25-2008
paulds paulds is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 11
Arrow 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 (permalink)  
Old 07-25-2008
Ikon's Avatar
Ikon Ikon is offline Forum Advisor  
Registered User
  
 

Join Date: Jul 2008
Location: Phoenix, Arizona
Posts: 669
Is this a homework question?

What have you tried so far?

Paste your code.
  #3 (permalink)  
Old 07-25-2008
paulds paulds is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 11
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 (permalink)  
Old 07-25-2008
paulds paulds is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 11
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 (permalink)  
Old 07-25-2008
Ikon's Avatar
Ikon Ikon is offline Forum Advisor  
Registered User
  
 

Join Date: Jul 2008
Location: Phoenix, Arizona
Posts: 669
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 (permalink)  
Old 07-25-2008
paulds paulds is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 11
Thumbs up

Quote:
Originally Posted by Ikon View Post
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
  #7 (permalink)  
Old 07-25-2008
paulds paulds is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 11
I found the solution.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:31 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0