Assuming that the double quotes in the first message are text to be matched and replaced (not just string delimiters), Krishna's suggested code might change some occurrences of jai/1 that are not between quotes.
The problem (as Krishna hinted) is that you can't use a character as a field delimiter if it appears in the RE you're trying to match nor if it appears in the replacement string unless you escape it. Krishna's suggestion was to escape the slash characters that are part of the RE and that are part of the replacement string. It is often easier to use a different delimiter as in:
You can use any character in a sed substitute command as a field separator except backslash (\) and the <newline> character.
This User Gave Thanks to Don Cragun For This Post:
Sorry for the duplicate thread this one is similar to the one in
https://www.unix.com/shell-programming-scripting/88132-awk-sed-script-read-values-parameter-files.html#post302255121
Since there were no responses on the parent thread since it got resolved partially i thought to open the new... (4 Replies)
Okay, title is kind of confusion, but basically, I have a lot of scripts on a server that I need to replace a ps command, however, the new ps command I'm trying to replace the current one with pipes to sed at one point. So now I am attempting to create another script that replaces that line.
... (1 Reply)
hi all,
attached you can find a small txt file ( .txt ),
GIVEN that past_scheduler="islip" and scheduler="mucf"
can somebody please tell me
WHY sed 's/-u '$past_scheduler'/-u '$scheduler'/g' .txt > .txt.temp fails ?
thanx (3 Replies)
Hello,
Can any perl experts help me convert my sed string to perl. I am unsuccessful with this.
I have to remove this string from html files OAS_AD('Top');
I have come up with this. However the requirement is in perl.
for find in $(find . -type f -name "file1.html") ; do cat $find |... (2 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)
Hi.....
I'm using sed command for replace the words in a file
cat >test.txt
My test.txt contains
Mary had a little ham
Mary fried a lot of spam
Jack ate a Spam sandwich
Jill had a lamb spamwich
Marry had a spicy wich
$ sed 's/wich$/mirchi/g' test.txt
output is:
Mary had a little ham... (24 Replies)
Hello All,
I have something like below
LDC100/rel/prod/libinactrl.a
LAA2000/rel/prod/libinactrl.a
I want to remove till first forward slash that is outputshould be as below
rel/prod/libinactrl.a
rel/prod/libinactrl.a
How can I do that ??? (8 Replies)
Hello,
I'm working with this command which I'm having trouble understanding it:
sed -e '1,$ s/SUB/N/g' < $1 > file.txt
Where SUB stand for an special character with code in ASCII is 0x1A, notepad read it as a right arrow.
Any help will be appreciated. (5 Replies)
Hi,
I am running a script sample.sh in bash environment .In the script i am using sed and awk commands which when executed individually from terminal they are getting executed normally but when i give these sed and awk commands in the script it is giving the below errors :-
./sample.sh: line... (12 Replies)
Hi All,
I'm relatively new to Unix scripting and am trying to get my head around piping.
I'm trying to take a header record from one file and prepend it to another file. I've done this by creating several temp files but i'm wondering if there is a cleaner way to do this.
I'm thinking... (10 Replies)
Discussion started by: BigCroyd
10 Replies
LEARN ABOUT SUNOS
paste
paste(1) User Commands paste(1)NAME
paste - merge corresponding or subsequent lines of files
SYNOPSIS
paste [-s] [-d list] file...
DESCRIPTION
The paste utility will concatenate the corresponding lines of the given input files, and write the resulting lines to standard output.
The default operation of paste will concatenate the corresponding lines of the input files. The NEWLINE character of every line except the
line from the last input file will be replaced with a TAB character.
If an EOF (end-of-file) condition is detected on one or more input files, but not all input files, paste will behave as though empty lines
were read from the files on which EOF was detected, unless the -s option is specified.
OPTIONS
The following options are supported:
-d list Unless a backslash character () appears in list, each character in list is an element specifying a delimiter character. If a
backslash character appears in list, the backslash character and one or more characters following it are an element specifying a
delimiter character as described below. These elements specify one or more delimiters to use, instead of the default TAB charac-
ter, to replace the NEWLINE character of the input lines. The elements in list are used circularly. That is, when the list is
exhausted, the first element from the list is reused.
When the -s option is specified:
o The last newline character in a file will not be modified.
o The delimiter will be reset to the first element of list after each file operand is processed.
When the option is not specified:
o The NEWLINE characters in the file specified by the last file will not be modified.
o The delimiter will be reset to the first element of list each time a line is processed from each file.
If a backslash character appears in list, it and the character following it will be used to represent the following delimiter
characters:
Newline character.
Tab character.
\ Backslash character.
Empty string (not a null character). If is immediately followed by the character x, the character X, or any character
defined by the LC_CTYPE digit keyword, the results are unspecified.
If any other characters follow the backslash, the results are unspecified.
-s Concatenate all of the lines of each separate input file in command line order. The NEWLINE character of every line except the
last line in each input file will be replaced with the TAB character, unless otherwise specified by the -d option.
OPERANDS
The following operand is supported:
file A path name of an input file. If - is specified for one or more of the files, the standard input will be used. The standard input
will be read one line at a time, circularly, for each instance of -. Implementations support pasting of at least 12 file operands.
USAGE
See largefile(5) for the description of the behavior of paste when encountering files greater than or equal to 2 Gbyte ( 2**31 bytes).
EXAMPLES
Example 1: Listing a directory in one column
example% ls | paste -d" " -
Example 2: Listing a directory in four columns
example% ls | paste - - - -
Example 3: Combining pairs of lines from a file into single lines
example% paste -s -d" t n" file
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of paste: LANG, LC_ALL, LC_CTYPE, LC_MES-
SAGES, and NLSPATH.
EXIT STATUS
The following exit values are returned:
0 Successful completion.
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWesu |
+-----------------------------+-----------------------------+
|CSI |Enabled |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO cut(1), grep(1), pr(1), attributes(5), environ(5), largefile(5), standards(5)DIAGNOSTICS
"line too long" Output lines are restricted to 511 characters.
"too many files" Except for -s option, no more than 12 input files may be specified.
"no delimiters" The -d option was specified with an empty list.
"cannot open file" The specified file cannot be opened.
SunOS 5.10 20 Dec 1996 paste(1)