LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 08: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, 09:07 AM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Something like this?
echo /etc/mtab | sed 's/\//\\\//g
 
Old 08-14-2004, 11:53 AM   #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, 03:28 PM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Sorry - my mistake. I left a ' off the end - try:
echo /etc/mtab | sed 's/\//\\\//g'
 
Old 08-14-2004, 04: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



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 06:38 AM
how to manipulate string in script? ringerxyz Programming 2 02-17-2005 01:14 AM
Bash Script String Splitting MurrayL Linux - Newbie 1 09-21-2004 03:20 AM
String manipulation with a script. philipina Programming 4 03-16-2004 02:42 PM
String manipulation with a script? philipina General 1 03-15-2004 12:07 PM

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

All times are GMT -5. The time now is 08:08 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
Open Source Consulting | Domain Registration