LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-14-2004, 09:36 AM   #1
MadCactus
Member
 
Registered: Jul 2003
Distribution: Slackware 9.1
Posts: 195

Rep: Reputation: 30
script string question


How would I take a filename string e.g. "/etc/mtab"

and change it so it could be used as an argument to gawk, since gawk doesn't accept forward slashes as the pattern?

I just need to insert backslashes so it would be: "\/etc\/mtab".

I'm using the bash shell.
 
Old 08-14-2004, 10:07 AM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
Something like this?
echo /etc/mtab | sed 's/\//\\\//g
 
Old 08-14-2004, 12:53 PM   #3
MadCactus
Member
 
Registered: Jul 2003
Distribution: Slackware 9.1
Posts: 195

Original Poster
Rep: Reputation: 30
Can that only be done from a script, as it doesn't seem to wrok on the command line?
 
Old 08-14-2004, 04:28 PM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
Sorry - my mistake. I left a ' off the end - try:
echo /etc/mtab | sed 's/\//\\\//g'
 
Old 08-14-2004, 05:44 PM   #5
MadCactus
Member
 
Registered: Jul 2003
Distribution: Slackware 9.1
Posts: 195

Original Poster
Rep: Reputation: 30
I feel my time as a Linux newbie has just expired, I fear no command now (except rm -rf of course). I won't bother to ask what it actually means.

Thanks.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script - String Replacement revof11 Programming 7 11-29-2005 07:38 AM
how to manipulate string in script? ringerxyz Programming 2 02-17-2005 02:14 AM
Bash Script String Splitting MurrayL Linux - Newbie 1 09-21-2004 04:20 AM
String manipulation with a script. philipina Programming 4 03-16-2004 03:42 PM
String manipulation with a script? philipina General 1 03-15-2004 01:07 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration