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 > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to add files to an existing tar file - HP-UNIX Nomaad UNIX for Dummies Questions & Answers 5 11-06-2008 05:27 AM
existing file to a fixed length file cmanand Shell Programming and Scripting 3 01-25-2008 05:50 PM
Creating a csv file based on Existing file skywayterrace Shell Programming and Scripting 3 12-02-2007 09:19 AM
i want to delete a file based on existing file in a directory srivsn Shell Programming and Scripting 3 04-11-2006 04:38 AM
Print one line of Existing File danhodges99 UNIX for Dummies Questions & Answers 2 02-25-2003 11:56 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-13-2001
darthur darthur is offline
Registered User
  
 

Join Date: Dec 2001
Location: Overland Patrk
Posts: 62
Question pasting text into an existing file

I have a text file that has over 300 lines that I need to paste identical data to. What is the easiest way to do this? For example if I have a file that has lines of text xxxxxxxx and I would like to change each line to look like this "display text(xxxxxxxx)". What would be the easiest way to do this? Would I do something like

cat xxxxx.txt while read line
do ?

This is what I currently have:
xxxxxxxx
xxxxxxxx
xxxxxxxx
xxxxxxxx
xxxxxxxx

This is what I want to change it to.
display text(xxxxxxxx)
display text(xxxxxxxx)
display text(xxxxxxxx)
display text(xxxxxxxx)
display text(xxxxxxxx)

Thanks,
  #2 (permalink)  
Old 12-13-2001
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,100
sed 's/^/display text (/;s/$/)/' < xxxxxx.txt
would probably be the easiest. But if you're intent on using a shell...
Code:
#! /usr/bin/ksh
exec < xxxxxx.txt
while read line ; do
      echo 'display text ('${line}')'
done
exit 0
  #3 (permalink)  
Old 12-13-2001
darthur darthur is offline
Registered User
  
 

Join Date: Dec 2001
Location: Overland Patrk
Posts: 62
Thanks! That worked like a charm.

Yu da man
  #4 (permalink)  
Old 12-13-2001
Jimbo
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
And here is an awk solution:

awk '{print "display text (" $0 ")"}' xxxxx.txt > newfile.txt
Sponsored Links
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 09:35 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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