I'm writting a krn shell script and i'm having an issue with a variable using sed.
If someone enters a variable with a " /" the sed command doesn't read it right.
example.
a='12000/10-DC'
b='12000/10-AC'
cat file | sed "s/$a/$b/"
How can i correct this issue? Will the fix to this... (2 Replies)
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)
Hi,
I have to replace the character AL2 with AL16 which I have in one of my text file .
I used the sed command like this
sed 's/sed 's/AL2/AL16/g' test_carr.dat>test_carr1.dat
But it is not replacing this value to the output file.
The test_carr.dat file contains data like this
cat... (1 Reply)
Hi everybody,
I have come across a typical problem:
I need to use sed command to replace an apostrophe but it is saying no match found in the error
sed -e 's/`/'/g' ...but it is not working. Can you please tell me how to use this apostrophe in this sed command please. Thanks.
Rubin (8 Replies)
I know this script is crummy, but I was just messing around.. how do I get sed's insert command to allow variable expansion to show the filename?
#!/bin/bash
filename=`echo $0`
/usr/bin/sed '/#include/ {
i\
the filename is `$filename`
}' $1
exit 0 (8 Replies)
I need to search for a keyword UTF-16 in a list of files if that keyword is found then i need to convert the file to UTF-8 format using iconv command.
After this i should substitute the UTF-16 keyword inside the file to UTF-8.
Please suggest how to do this in shell scripting. (11 Replies)
I have a file that contains lines like this:
allgroups: cn=Role1,cn=groups,o=xyz,st=mn,c=us
allgroups: cn=Role1,cn=groups,o=xyz,st=mn,c=us
I want to remove the string :
,cn=groups,o=xyz,st=mn,c=us
and so I tried to use SED. i tried to assign it to a variable and use it:
... (3 Replies)
Hi All,
I am using the below script which has awk command, but it is not returing the expected result. can some pls help me to correct the command.
The below script sample.ksh should give the result if the value of last 4 digits in the variable NM matches with the variable value DAT. The... (7 Replies)
Hi,
I want to use a code like
sed -n "1,9988p" filename | wc -l
I tried
from=1
till=9988
sed -n "/$from/,/$till/p" filename |wc -l
Issue:
sed -n "1,9988p" filename | wc -l -- Returns 9988 rows
But
sed -n "/$from/,/$till/p" filename |wc -l # Returns > 9988 rows(Complete file)
I... (2 Replies)
Hi,
I have a script that replaces one string with the other in all files under the specified directory.
!/bin/bash
# **************** Change Variables Here ************
startdirectory="/opt/app/properties/tmp_new"
searchterm="Oracle/Middleware/"
replaceterm=""
#... (1 Reply)
Discussion started by: mohtashims
1 Replies
LEARN ABOUT OSF1
mrd
mrd(1) General Commands Manual mrd(1)NAME
mrd - mtools utility to remove a DOS directory
SYNOPSIS
mrd msdosdirectory [msdosdirectories...]
DESCRIPTION
The mrd command removes a directory from a DOS file system. If the directory is not empty, an error occurs. Unlike DOS conventions, this
command allows multiple arguments.
DOS subdirectory names that contain the '/' or '' separator are supported. If you use the '' separator or wildcards, you must enclose
file names in quotes to protect them from the shell.
The mcd command can be used to establish the device and the current working directory (relative to DOS), otherwise the default is A:.
EXIT STATUS
The following exit values are returned: Success. Failure.
ENVIRONMENT VARIABLES
The following environment variables affect the execution of mrd: If set, this variable names the file that contains the name of the current
mtools working directory as established by the mcd command. If this variable is not set, the file $HOME/.mcwd is used.
FILES
Contains the name of the current mtools working directory as established by the mcd command. If this file does not exist, the default
mtools working directory is A:. Executable file
SEE ALSO
Commands: mcd(1), mmd(1), mtools(1)mrd(1)