The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
"sed" to check file size & echo " " to destination file jockey007 Shell Programming and Scripting 7 04-28-2009 03:08 AM
Can I make "touch" create executable files by manipulating umask? tphyahoo Shell Programming and Scripting 2 01-30-2009 04:20 PM
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-20-2007 01:52 AM
how could i make a program mixed with many "|", "<" and ">" strugglingman High Level Programming 2 04-29-2006 09:11 AM
"./cofigure" and "make" turmoil gnerd UNIX for Dummies Questions & Answers 16 02-23-2004 04:53 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 Rate Thread Display Modes
  #1 (permalink)  
Old 10-06-2007
cdfd123 cdfd123 is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 112
Smile how to make ABC into "ABC" ina file

suppose u have a file
ABC CDF ADF FDG HAA AHH AHA

so output shud be like
"ABC" "CDF" "ADF" FDG " "HAA" "AHH" "AHA"
  #2 (permalink)  
Old 10-06-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965

Code:
while read N
do
   for d in N
   do
       echo \"$d\"
   done
done <file

  #3 (permalink)  
Old 10-06-2007
radoulov's Avatar
radoulov radoulov is online now Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,926

Code:
sed 's/[^ ]*/"&"/g' filename

  #4 (permalink)  
Old 10-06-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958

Code:
echo "ABC CDF ADF FDG HAA AHH AHA" | awk '{ for ( i=1; i<=NF; i++ ) { printf "\"%s\" ", $i } }END{ printf "\n" }'

  #5 (permalink)  
Old 10-06-2007
devtakh devtakh is offline
Registered User
  
 

Join Date: Oct 2007
Location: Bangalore
Posts: 514
as simple as this...using sed..

sed 's/[a-zA-Z]*/"&"/g' filename


cheers,
Devaraj Takhellambam
  #6 (permalink)  
Old 10-07-2007
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,092
sed

Hi, try this one.


Code:
echo ABC CDF ADF FDG HAA AHH AHA | sed 's/\([a-zA-Z]\{3\}\)/\"&\"/g'

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:13 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