Append this string to end of each line | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


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

Append this string to end of each line

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-06-2013
omega3 omega3 is offline
Registered User
 
Join Date: Sep 2012
Last Activity: 2 June 2014, 10:49 AM EDT
Posts: 28
Thanks: 29
Thanked 1 Time in 1 Post
Append this string to end of each line

Platform: Solaris 10

I have a file like below


Code:
$ cat languages.txt
Spanish
Norwegian
English
Persian
German
Portugese
Chinese
Korean
Hindi
Malayalam
Bengali
Italian
Greek
Arabic

I want to append the string " is a great language" at end of each line in this file.

Expected output:


Code:
Spanish is a great language
Norwegian is a great language
English is a great language
Persian is a great language
German is a great language
Portugese is a great language
Chinese is a great language
Korean is a great language
Hindi is a great language
Malayalam is a great language
Bengali is a great language
Italian is a great language
Greek is a great language
Arabic is a great languages

How can I do this?
Sponsored Links
    #2  
Old 06-06-2013
balajesuri's Avatar
balajesuri balajesuri is offline Forum Advisor  
#! /bin/bash
 
Join Date: Apr 2009
Last Activity: 21 July 2014, 11:56 PM EDT
Location: India
Posts: 1,816
Thanks: 24
Thanked 519 Times in 498 Posts

Code:
sed 's/$/ is a great language/' languages.txt

The Following User Says Thank You to balajesuri For This Useful Post:
omega3 (06-07-2013)
Sponsored Links
    #3  
Old 06-06-2013
pamu pamu is offline
Registered User
 
Join Date: Mar 2012
Last Activity: 1 July 2014, 5:40 AM EDT
Posts: 1,649
Thanks: 58
Thanked 478 Times in 474 Posts
with awk..


Code:
awk '{$0=$0" is a great language"}1' languages.txt

The Following User Says Thank You to pamu For This Useful Post:
omega3 (06-07-2013)
    #4  
Old 06-06-2013
juzz4fun juzz4fun is offline
Registered User
 
Join Date: May 2013
Last Activity: 10 February 2014, 11:54 AM EST
Posts: 127
Thanks: 24
Thanked 16 Times in 16 Posts
awk '{print $0 " is a great language"}' input
The Following User Says Thank You to juzz4fun For This Useful Post:
omega3 (06-07-2013)
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Search for a string, then append character to end of that line only snoman1 Shell Programming and Scripting 1 11-27-2012 01:25 PM
Append the end of each line in a file with a given string nmattam Shell Programming and Scripting 10 02-25-2010 08:47 AM
Append a string at the end of every line in a file nmattam Shell Programming and Scripting 1 02-22-2010 09:38 AM
How can I append a string at the end of a line in a file daikeyang Shell Programming and Scripting 5 03-22-2009 09:01 PM
HOWTO Append String to End of Line bggibson UNIX for Dummies Questions & Answers 3 08-15-2008 04:04 PM



All times are GMT -4. The time now is 08:33 PM.