Sponsored Content
Top Forums Shell Programming and Scripting Need assistance with appending strings using sed and variables Post 302235234 by mandriver on Thursday 11th of September 2008 11:43:33 AM
Old 09-11-2008
Need assistance with appending strings using sed and variables

HI,

Can't seem to find anything on the forums to fix this.

I have a file, one line within this will not have a specific string at the end.

I have the string, but need to append it to the specific line which has it missing.

I need to use a variable for this, $string - I am using double quotes as below:

sed "/!*missing_string/a\ $string" file

Any help would be much appreciated.

Many thanks
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

appending strings in the files

I have some files created by a process in UNIX. I wanted to do some file processing: 1. I want to append a string "EOF" as the first word on the last line of all the files except the last file. 2.Similarly, I want to append "BOF" string as the first word to all the files except the first... (2 Replies)
Discussion started by: vijaylak
2 Replies

2. Shell Programming and Scripting

appending strings to variable

is it possible? as i keep reading a file, i want one particular variable to keep storing the line that i've read so far (1 Reply)
Discussion started by: finalight
1 Replies

3. Shell Programming and Scripting

appending strings

Hi , while trying to append two strings, it is not properly coming. my code will be like this str1=_TrackingEAR srt2=1.0.0-20080523.155438-12 i am trying to build str3=$str1$str2.tgz but it is appending the last value ot the begingin of the string , but i expect to the end of the... (1 Reply)
Discussion started by: scorpio
1 Replies

4. Shell Programming and Scripting

Appending variables

Hi, I'm having a problem with something I can't really figure out by myself. I've tried to do it with a for loop, but I'm pretty sure it won't work, if I'm not mistaken. Basically, what I'm trying to do is test some variables and if any of them is not empty, add the values of these variables... (5 Replies)
Discussion started by: mutex1
5 Replies

5. Shell Programming and Scripting

appending two strings

Hi, I have a small doubt. Here is the code snippet for which the output that I'm getting are a bit surprising. testing.sh #!/bin/sh arg_1=$1 echo "arg passed by user is:${arg_1}" mapping=`grep ${arg_1}= testing.conf | awk -F"=" '{print $2}'` echo "mapping is $mapping"... (4 Replies)
Discussion started by: badrimohanty
4 Replies

6. Shell Programming and Scripting

replace two character strings by two variables with sed command

Hello, I want to writte a script that replace two character strings by two variables with the command sed butmy solution doesn't work. I'm written this: sed "s/TTFactivevent/$TTFav/g && s/switchSLL/$SLL/g" templatefile. I want to replace TTFactivevent by the variable $TTFav, that is a... (4 Replies)
Discussion started by: POPO10
4 Replies

7. Shell Programming and Scripting

Need assistance with sed

Hi All, I need your assistance, I would like to replace all lines beginning with the word "begin" with the below text: Device | IPMB0-A | IPMB0-B Board Address |Sent SentErr %Errr |Sent SentErr ... (9 Replies)
Discussion started by: Dendany83
9 Replies

8. UNIX for Advanced & Expert Users

Need assistance with sed

Hi All, I need your assistance, I would like to replace all lines beginning with the word "begin" with the below text: Device | IPMB0-A | IPMB0-B Board Address |Sent SentErr %Errr |Sent SentErr ... (10 Replies)
Discussion started by: Dendany83
10 Replies

9. Shell Programming and Scripting

sed assistance

Hello everyone. I am trying to replace sprintf(buffer, "{\"id\":1,\"method\":\"mining.update_block\",\"params\":}\n", coinid, blockhash); with sprintf(buffer, "{\"id\":1,\"method\":\"mining.update_block\",\"params\":}\n", coinid, blockhash); this is the code I was trying but is... (9 Replies)
Discussion started by: crombiecrunch
9 Replies

10. UNIX for Beginners Questions & Answers

Assistance to connect to servers via ssh once and collect various commands into separate variables

Hello, We use as bash script to connect to servers listed in an .csv file to issue commands against these servers and retrieve data to be saved in a .csv file. The data we want to collect is saved in variables. We issue an ssh command for each variable we want to capture. I'm thinking this is... (9 Replies)
Discussion started by: greavette
9 Replies
RBASH(1)						      General Commands Manual							  RBASH(1)

NAME
rbash - restricted bash, see bash(1) RESTRICTED SHELL
If bash is started with the name rbash, or the -r option is supplied at invocation, the shell becomes restricted. A restricted shell is used to set up an environment more controlled than the standard shell. It behaves identically to bash with the exception that the follow- ing are disallowed or not performed: o changing directories with cd o setting or unsetting the values of SHELL, PATH, ENV, or BASH_ENV o specifying command names containing / o specifying a file name containing a / as an argument to the . builtin command o specifying a filename containing a slash as an argument to the -p option to the hash builtin command o importing function definitions from the shell environment at startup o parsing the value of SHELLOPTS from the shell environment at startup o redirecting output using the >, >|, <>, >&, &>, and >> redirection operators o using the exec builtin command to replace the shell with another command o adding or deleting builtin commands with the -f and -d options to the enable builtin command o using the enable builtin command to enable disabled shell builtins o specifying the -p option to the command builtin command o turning off restricted mode with set +r or set +o restricted. These restrictions are enforced after any startup files are read. When a command that is found to be a shell script is executed, rbash turns off any restrictions in the shell spawned to execute the script. SEE ALSO
bash(1) GNU Bash-4.0 2004 Apr 20 RBASH(1)
All times are GMT -4. The time now is 12:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy