The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Contact Us (Meet Our Management Team) > Post Here to Contact Site Administrators and Moderators
.
google unix.com



Post Here to Contact Site Administrators and Moderators Registered Users make ask questions and suggestions about forums, features, or content here. Get forum support here, not via email!!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
TOP Command problem Sgiri1 UNIX for Dummies Questions & Answers 2 09-24-2008 04:33 AM
problem with tr command ravi raj kumar UNIX for Advanced & Expert Users 2 07-02-2007 06:41 AM
problem with dd command or maybe AFS problem Anta Shell Programming and Scripting 0 08-25-2006 10:10 AM
ls command problem buckhtr77 SUN Solaris 2 12-06-2005 04:16 PM
Problem while using Sed command gopskrish UNIX for Dummies Questions & Answers 2 06-27-2005 11:26 AM

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

Join Date: Dec 2008
Posts: 2
AWK command problem

How can I write an AWK so it could print some fixed strings and concatenate that with other words from an input file. Also having a string like "go" in the next line in the output file as below:

Example:

A fixed string like: "Hello my"

and the input file is:

friend
mother
father
son
sister
brother

the output would be:

Hello my friend.
go
Hello my mother.
go
Hello my father.
go
Hello my son.
go
.
.
.

Thanks a lot,
  #2 (permalink)  
Old 12-04-2008
Ikon's Avatar
Ikon Ikon is offline Forum Advisor  
Registered User
  
 

Join Date: Jul 2008
Location: Phoenix, Arizona
Posts: 669
Code:
awk '{ print "Hello my " $0; }' myfile.txt
  #3 (permalink)  
Old 12-04-2008
sybase08 sybase08 is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 2
Thanks Ikon for your comment.

I also need a new line with the string "go" to be appeared at the next line. example:


Hello my friend.
go
Hello my mother.
go

how can i acheive that?

Thanks,
  #4 (permalink)  
Old 12-04-2008
Ikon's Avatar
Ikon Ikon is offline Forum Advisor  
Registered User
  
 

Join Date: Jul 2008
Location: Phoenix, Arizona
Posts: 669
Code:
awk '{ print "Hello my " $0 "\ngo";}' test.txt
  #5 (permalink)  
Old 12-04-2008
DukeNuke2's Avatar
DukeNuke2 DukeNuke2 is offline Forum Staff  
Soulman
  
 

Join Date: Jul 2006
Location: Germany, Berlin
Posts: 2,951
posted in the wrong forum and also looks like homework. thread closed.
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 01:35 PM.


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