LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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 11-19-2005, 05:56 PM   #1
rharris72
Member
 
Registered: Nov 2005
Posts: 32

Rep: Reputation: 15
sed command


i am trying to help a buch of guys edit files for gaming servers using questions user input then sed command but if they put a space into the sting it fails can any one help

echo "Please give server name "

read name
sed s/clan/$name/g server.cfg > cfg.cfg

if they dont type spaces its fine

as soon as say they type "clan server"

the script fails is there a way of letting them use spaces
as bit of a pain in the rear can only use one word or a long sentence with no spaces
 
Old 11-19-2005, 06:41 PM   #2
shanenin
Member
 
Registered: Aug 2003
Location: Rochester, MN, U.S.A
Distribution: Gentoo
Posts: 987

Rep: Reputation: 30
you need to enclose your sed command in quotes
Code:
sed "s/clan/$name/g" server.cfg > cfg.cfg

Last edited by shanenin; 11-19-2005 at 06:42 PM.
 
Old 11-20-2005, 02:46 AM   #3
rharris72
Member
 
Registered: Nov 2005
Posts: 32

Original Poster
Rep: Reputation: 15
thanks such a simple answer and work boy do i feel stupid lol
 
Old 11-20-2005, 05:21 AM   #4
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 46
http://main.rtfiber.com.tw/~changyj/sed/
 
Old 11-20-2005, 07:57 AM   #5
eddiebaby1023
Member
 
Registered: May 2005
Posts: 378

Rep: Reputation: 33
Quote:
Originally posted by rharris72
thanks such a simple answer and work boy do i feel stupid lol
Don't feel stupid, lots of people don't seem to know how to use quotes - they just throw them in until things seem to work. Time invested in learning how to use single and double quotes properly will repay you many times over in saved time when you get it right first time. As an example, see the difference in the following:
Code:
VAR="a     b          c                         d"
echo $VAR
echo "$VAR"
echo '$VAR'
 
Old 11-20-2005, 02:24 PM   #6
rharris72
Member
 
Registered: Nov 2005
Posts: 32

Original Poster
Rep: Reputation: 15
ok thanks do you also know how i can soft or hard link folders so i can have say one folder with main game files in and another with the links in to the folder plus the server.cfg file for there individual server

i know im asking alot but hey i'm learning fast

thanks
 
Old 11-20-2005, 08:26 PM   #7
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 46
Quote:
do you also know how i can soft or hard link folders so i can have say one folder with main game files in and another with the links in to the folder plus the server.cfg file for there individual server
lndir
Code:
NAME
       lndir  -  create a shadow directory of symbolic links to another direc-
       tory tree

SYNOPSIS
       lndir [ -silent ] [ -ignorelinks ] [ -withrevinfo ] fromdir [ todir ]

DESCRIPTION
       The lndir program makes  a  shadow  copy  todir  of  a  directory  tree
       fromdir,  except  that  the shadow is not populated with real files but
       instead with symbolic links pointing at the real files in  the  fromdir
       directory tree.  This is usually useful for maintaining source code for
       different machine architectures.  You create a  shadow  directory  con-
       taining  links  to the real source, which you will have usually mounted
       from a remote machine.  You can build  in  the  shadow  tree,  and  the
       object files will be in the shadow directory, while the source files in
       the shadow directory are just symlinks to the real files.
 
  


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
sed command Kalyani1 Linux - Software 28 12-07-2005 11:48 AM
sed command pazvant Linux - Software 2 05-09-2004 12:58 PM
sed command linuxdev Linux - Newbie 9 02-24-2004 04:50 PM
sed Command linuxdev Linux - Newbie 3 02-09-2004 11:27 AM
sed command kwigibo Linux - General 3 04-21-2002 04:11 PM


All times are GMT -5. The time now is 03:34 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration