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 string manipulation speedieB Shell Programming and Scripting 4 11-23-2008 08:27 PM
string manipulation james6 UNIX for Dummies Questions & Answers 5 06-03-2008 11:05 AM
string manipulation Cactus Jack Shell Programming and Scripting 9 02-14-2008 01:14 PM
String Manipulation kakashi_jet Shell Programming and Scripting 7 01-10-2007 01:25 AM
string manipulation in C trinath High Level Programming 1 01-23-2006 11:13 AM

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 06-16-2008
hikrishn hikrishn is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 4
Smile How to use sed for string manipulation

Hi,

I would like to know How to use use sed for manipulating string for the following situation.
Basically my objective is to check validity of the filename in my shell script.
I am getting a parameter like this for my shell script.
Check my folder is having some space.

$1=/root/krishna mohan/file.txt

I am trying to use sed so that I can mutate the above file path like below and further use ls command.
/root/'krishna mohan'/file.txt

ls /root/'krishna mohan'/file.txt

Ofcourse I do know that I can use single quote in the begining and end.But I will have problems if I am getting above parameter with some mask/pattern like
/root/krishna mohan/file*.txt
Here keeping single quotes in the begining and end won't work.

Kindly suggest me the solution How to keep quotes for any text between / and / which has space.
  #2 (permalink)  
Old 06-16-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,540
when you use the variable $1, use double quotes.
  #3 (permalink)  
Old 06-16-2008
hikrishn hikrishn is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 4
Quote:
Originally Posted by ghostdog74 View Post
when you use the variable $1, use double quotes.
yeah But it is not working in following case..can u pls suggest on this
Here is the input parameter it comes for me.

$ ./sample.ksh '/root/krishna mohan/file*.txt'

sample.ksh
********

input="$1"

ls -m $input
ls -m "$input"

**********

above command are not able to interpret and list the exact files..

Thanks
Krishna
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 11:19 AM.


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