Sponsored Content
Full Discussion: BASH -- sed -- variable
Top Forums Shell Programming and Scripting BASH -- sed -- variable Post 302188549 by Imajean on Wednesday 23rd of April 2008 08:18:03 PM
Old 04-23-2008
BASH -- sed -- variable

Hi, I'm new at bash scripting -- can anyone here help me about the sed command?

I need to be able to edit and or delete a text from an outside file ie file.txt -- I'm passing a variable and not a string

I was thinking of something like

echo -n "What do you want to edit?: "
read edit
sed -e '$edit' file.txt

??? thanks in advance!!! Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

passing variable from bash to perl from bash script

Hi All, I need to pass a variable to perl script from bash script, where in perl i am using if condition. Here is the cmd what i am using in perl FROM_DATE="06/05/2008" TO_DATE="07/05/2008" "perl -ne ' print if ( $_ >="$FROM_DATE" && $_ <= "$TO_DATE" ) ' filename" filename has... (10 Replies)
Discussion started by: arsidh
10 Replies

2. Shell Programming and Scripting

Sed variable substitution when variable constructed of a directory path

Hello, i have another sed question.. I'm trying to do variable substition with sed and i'm running into a problem. my var1 is a string constructed like this: filename1 filerev1 filepath1 my var2 is another string constructed like this: filename2 filerev2 filepath2 when i do... (2 Replies)
Discussion started by: alrinno
2 Replies

3. Shell Programming and Scripting

bash and ksh: variable lost in loop in bash?

Hi, I use AIX (ksh) and Linux (bash) servers. I'm trying to do scripts to will run in both ksh and bash, and most of the time it works. But this time I don't get it in bash (I'm more familar in ksh). The goal of my script if to read a "config file" (like "ini" file), and make various report.... (2 Replies)
Discussion started by: estienne
2 Replies

4. Shell Programming and Scripting

Special characters in a bash variable in sed

Hello, I am trying the following: echo __CHANGEME__ >> testfile VAR1="&&&" sed -i "s|__CHANGEME__|${VAR1}|" testfile cat testfile This results in testfile containing __CHANGEME____CHANGEME____CHANGEME__ Whereas I want it to result in &&& I understand that if VAR1="\&\&\&" then... (3 Replies)
Discussion started by: linuxnewbeee
3 Replies

5. Shell Programming and Scripting

Insert a line including Variable & Carriage Return / sed command as Variable

I want to instert Category:XXXXX into the 2. line something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong: sed "2i\\${n}Category:$cat\n" Sample: Titel Blahh Blahh abllk sdhsd sjdhf Blahh Blah Blahh Blahh Should look like... (2 Replies)
Discussion started by: lowmaster
2 Replies

6. Shell Programming and Scripting

bash - Variable made of variable

Hello, I am struggling with using variable made using "eval". a=4 eval b$a=20 echo $b$a ??? As shown above, I am trying to call back the variable "bX" assuming I do not know the value of "a". How can I do that? I tried several combinations but nothing worked. Thanks (10 Replies)
Discussion started by: jolecanard
10 Replies

7. Shell Programming and Scripting

Expand an environment variable in sed, when the variable contains a slash

I'm trying to make a sed substitution where the substitution pattern is an environment variable to be expanded, but the variable contains a "slash". sed -e 's/<HOME_DIRECTORY>/'$HOME'/'This gives me the following error: sed: -e expression #1, char 21: unknown option to `s'Obviously this is... (2 Replies)
Discussion started by: Ilja
2 Replies

8. Shell Programming and Scripting

bash variable (set via awk+sed) not working as expected

Hi! Been working on a script and I've been having a problem. I've finally narrowed it down to this variable I'm setting: servername=$(awk -v FS=\/ '{ print $7 } blah.txt | sed 's\/./-/g' | awk -v FS=\- '{print $1}')" This will essentially pare down a line like this: ... (7 Replies)
Discussion started by: creativedynamo
7 Replies

9. Red Hat

How to pass value of pwd as variable in SED to replace variable in a script file

Hi all, Hereby wish to have your advise for below: Main concept is I intend to get current directory of my script file. This script file will be copied to /etc/init.d. A string in this copy will be replaced with current directory value. Below is original script file: ... (6 Replies)
Discussion started by: cielle
6 Replies

10. Shell Programming and Scripting

Need bash script to use a sed command as a variable

I need to be able to use a sed command as a variable in a bash script. I have the sed command that almost works the way I want it. the command is sed -n '/inet/,/}/p' config.boot This gets me this result: inet 192.168.1.245 } I need to get the IP address into a variable so I... (9 Replies)
Discussion started by: edlentz
9 Replies
EXO-DESKTOP-ITEM-EDIT(1)					   User Commands					  EXO-DESKTOP-ITEM-EDIT(1)

NAME
exo-desktop-item-edit - Create icons on the desktop DESCRIPTION
Usage: exo-desktop-item-edit [OPTION...] [FILE|FOLDER] Help Options: -?, --help Show help options --help-all Show all help options --help-gtk Show GTK+ Options Application Options: -c, --create-new Create a new desktop file in the given directory -t, --type Type of desktop file to create (Application or Link) --name Preset name when creating a desktop file --comment Preset comment when creating a desktop file --command Preset command when creating a launcher --url Preset URL when creating a link --icon Preset icon when creating a desktop file -v, --version Print version information and exit --display=DISPLAY X display to use AUTHOR
Written by Benedikt Meurer <benny@xfce.org>. exo-desktop-item-edit comes with ABSOLUTELY NO WARRANTY, You may redistribute copies of exo-desktop-item-edit under the terms of the GNU Lesser General Public License which can be found in the exo source package. Please report bugs to <http://bugzilla.xfce.org/>. COPYRIGHT
Copyright (C) 2005-2006 os-cillation e.K. All rights reserved. SEE ALSO
The full documentation for exo-desktop-item-edit is maintained as a Texinfo manual. If the info and exo-desktop-item-edit programs are properly installed at your site, the command info exo-desktop-item-edit should give you access to the complete manual. exo-desktop-item-edit 0.3.1.10rc1 September 2006 EXO-DESKTOP-ITEM-EDIT(1)
All times are GMT -4. The time now is 04:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy