The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Search for strings & copy to new file amitrajvarma Shell Programming and Scripting 2 11-25-2007 11:51 PM
Delete strings in a file ayhanne Shell Programming and Scripting 8 11-09-2007 09:48 AM
Help with extracting strings from a file cmsdelhi Shell Programming and Scripting 7 01-12-2007 09:49 AM
Please Help. Strings in file 1 need to be searched and removed from file 2 mjs3221 Shell Programming and Scripting 4 08-18-2006 04:13 PM
How to concatenate two strings or several strings into one string in B-shell? fontana Shell Programming and Scripting 2 08-26-2005 12:58 PM

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 Rating: Thread Rating: 1 votes, 4.00 average. Display Modes
  #1 (permalink)  
Old 05-09-2007
Jolly Jolly is offline
Registered User
  
 

Join Date: May 2007
Posts: 8
Question Put strings around the file name

I have a file(old file) with names in it like
Jolly Mirani
Han Lee
stuart Lloyd

I want string to be added to these names . New file should look like
'jolly mirani'
'han lee'
'stuart lloyd'

I tried using sed command but doesn't work for string but it do work for paranthesis. Can some one help me with the code for the same.

sed 's/[^][^]*/(&)/g' <old file> new file
  #2 (permalink)  
Old 05-09-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Code:
sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' -e "s/^/\'/" -e "s/$/\'/" file
  #3 (permalink)  
Old 05-09-2007
Jolly Jolly is offline
Registered User
  
 

Join Date: May 2007
Posts: 8
Thanks

it worked properly
  #4 (permalink)  
Old 05-09-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,553
another:
Code:
awk ' {  $0 = tolower($0); print "\047"$0"\047"} ' "file"
output:
Code:
# ./test.sh
'jolly mirani'
'han lee'
'stuart lloyd'
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:11 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