Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Append this string to end of each line

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 06-06-2013
omega3 omega3 is offline
Registered User
 
Join Date: Sep 2012
Last Activity: 18 November 2015, 4:37 AM EST
Posts: 31
Thanks: 31
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 Unix and Linux 06-06-2013
balajesuri's Unix or Linux Image
balajesuri balajesuri is offline Forum Advisor  
#! /bin/bash
 
Join Date: Apr 2009
Last Activity: 22 September 2016, 12:12 PM EDT
Location: India
Posts: 1,957
Thanks: 30
Thanked 565 Times in 541 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 Unix and Linux 06-06-2013
pamu pamu is offline
Registered User
 
Join Date: Mar 2012
Last Activity: 8 August 2016, 12:07 PM EDT
Posts: 1,650
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 Unix and Linux 06-06-2013
juzz4fun juzz4fun is offline
Registered User
 
Join Date: May 2013
Last Activity: 7 March 2016, 5:05 PM 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 Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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:12 PM.