Have tried various forms of sed (with single quotes, without quotes, with -e option, etc) but getting the same error with all:
You are getting that error because the shell variable, ${b}, is unset or null. After its expansion, the sed command becomes s//15/g. In sed, an empty regular expression is equivalent to the most recently used regular expression. Since there is none, you get that error.
Hello everyone,
I need to replace a pattern with "value of a variable" using sed but no luck.
i tried the below
ABC=STR2
sed 's/STR1/$ABC/g' <file>
(also tried \ , $ and " in combination but failed)
Appreciate any help.
Thanks
Prvn (2 Replies)
Hi,
i call my shell like:
my_shell "my project name"
my script:
#!/bin/bash -vx
projectname=$1
sed s/'PROJECT_NAME ='/'PROJECT_NAME = '$projectname/ <test_config_doxy >temp
cp temp test_config_doxy
the following error occurres:
sed s/'PROJECT_NAME ... (2 Replies)
Ok, so, let's say I have the variable $GMAILID....How can I use it with sed command so to replace a string in a file? e.g.:
sed -i 's/$GMAILID/test@gmail.com/' /home/$USER/Desktop/sendmail (4 Replies)
I have a requirement where i have a sql file (filetext.sql). This file contains a variable ss_code.
Now in a shell script im trying to replace the variable ss_code with a value contained in the shell script variable MTK_DC..tried the below in the script
MTK_DC="mit,cit,bit"
OUT=`awk -v... (4 Replies)
Can someone tell me how I can do this?
e.g:
a=$(echo -e wert trewt ertert ertert ertert erttert
erterte
rterter
tertertert
ert)
How do i replace the STRING with $a?
I try this:
sed -i 's/STRING/'"$a"'/g' filename.ext
but this don' t work (2 Replies)
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)
My first comment on every file contains the license message. I want to replace with a new license message. I used the below sed script, which replaces all comments. What is the modification or any other method with awk script for the below to edit only the first comment(license message)?
#sed -f... (1 Reply)
I have a file having some text like:
PATH_ABC=/user/myLocation
I have to replace "/user/myLocation" with a session variable say, $REPLACE_PATH,
where $REPLACE_PATH=/user/myReplaceLocation
The following sed command is not working. It is writing PATH_ABC=$REPLACE_PATH in the file
... (2 Replies)
Hello everyone,
In one of my shell script I am doing sed/replace using a variable to find a string in a file & replace it with another string in same file.
The challenge which I am facing is that, the variable which I am using with "sed" is having one of character as "/"
Here is below how... (4 Replies)
Hi All
I have one file with multiple lines in it, each line has static text and some variable enclosed in <<filename>> as well. e.g. as below
123, <<file1.txt>> this is my name, I stay at <<city.txt>> Thanks for visiting
348384y, this is my name <<fileabc.txt>>, I stay at near the mall of... (8 Replies)
Discussion started by: reldb
8 Replies
LEARN ABOUT NETBSD
script
SCRIPT(1) BSD General Commands Manual SCRIPT(1)NAME
script -- make typescript of terminal session
SYNOPSIS
script [-adfpqr] [-c command] [file]
DESCRIPTION
script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive
session as proof of an assignment, as the typescript file can be printed out later with lpr(1).
If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the file typescript.
Option:
-a Append the output to file or typescript, retaining the prior contents.
-c command
Run the named command instead of the shell. Useful for capturing the output of a program that behaves differently when associated
with a tty.
-d When playing back a session with the -p flag, don't sleep between records when playing back a timestamped session.
-f Flush output after each write. This is useful for watching the script output in real time.
-p Play back a session recorded with the -r flag in real time.
-q Be quiet, and don't output started and ended lines.
-r Record a session with input, output, and timestamping.
The script ends when the forked shell exits (a control-D to exit the Bourne shell (sh(1)), and exit, logout or control-d (if ignoreeof is not
set) for the C-shell, csh(1)).
Certain interactive commands, such as vi(1), create garbage in the typescript file. script works best with commands that do not manipulate
the screen, the results are meant to emulate a hardcopy terminal.
ENVIRONMENT
The following environment variable is used by script:
SHELL If the variable SHELL exists, the shell forked by script will be that shell. If SHELL is not set, the Bourne shell is assumed. (Most
shells set this variable automatically).
SEE ALSO csh(1) (for the history mechanism).
HISTORY
The script command appeared in 3.0BSD.
BUGS
script places everything in the log file, including linefeeds and backspaces. This is not what the naive user expects.
BSD October 17, 2009 BSD