Note: The use of \| for alternation is a GNU extension
Since one would need to use GNU sed anyway, one might as well use its -r option for extended regular expressions:
or
--
In regular sed:
Last edited by Scrutinizer; 01-15-2017 at 10:11 AM..
Reason: Adedd s/^&$/\&\&/ ; thanks Don. For clarity sake and to avoid back reference, used \& rather than & in sed replacement part
This User Gave Thanks to Scrutinizer For This Post:
Hi,
I would like to seek help on how i can arrive on this result.
sample.txt:
product_code IN (param001) and product_type IN (param004)
product_code IN (param002) and product_type IN (param005)
product_code IN (param003) and product_type IN (param006)
I would like to change the param001... (1 Reply)
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)
Hello,
I have this command and it works fine.
My question is that how can we replace the N by a variable, to print for instance a big number of lines. It means if I want 100 lines after an expression, to not put "N" 100 times in the sed.
Code:
$ sed -n '/aaa/{n;N;N;s///g;s/;/; /g;p;}'... (2 Replies)
Hi All,
I have a file having one line only.
It is like
trapsess:inform|10.232.167.18|1|1|50|25|0|0|0|5|1|1|78|0037|
I want to replace the numbers in last two columns by As.
It should look like
trapsess:inform|10.232.167.18|1|1|50|25|0|0|0|5|1|1|AA|AAAA|
Please, suggest me any shell... (12 Replies)
Hi,
I have been trying to replace the key word
"SQL> spool off "
with
"/
show errors"
with out double quotes in all the files in a directory.
above show erros should be displayed next line
Could you please help me how to do that.
I have tried something like this... (3 Replies)
Hello All,
I need a sed command to find and replace below text in multiple files in a directory.
Original Text :- "$SCRIPT_PATH/files"
Replace with :- "$RESOURCE_FILE"
Thank you in advance !!!
Regards,
Anand Shah (1 Reply)
The content of the file filea.txt is as follows.
---------
case $HOSTNAME in
aaa)
DS_PARM_VALUE_SET=vsDev
APT_Configuration_File=/appl/infoserver/Server/Configurations/2node.apt
;;
bbb)
DS_PARM_VALUE_SET=vsQA... (3 Replies)
In a shell script I am replacing the asterisks in a file:
sed "s/\*/"0"/g" /home/download/$COMPANY_CODE/file_new > /home/download/$COMPANY_CODE/fileI need to log which positions were replaced & position(01:20) from the line it was replaced in. I am not sure how to do so. Also, instead of... (11 Replies)
Hi ,
My input file contain :
list = 3 14 15 10 9 11 12 18 19 20 21 22 23 24 25 26 6 1 2 3 4 5 7 8 16 17 27 28 30 29
Expected output :
list = 0 0 0 0 0 0 0 18 0 20 0 0 0 0 0 0 6 0 0 3 4 0 0 0 0 0 0 0 0 0
I want to keep the 8,10,16,17,22 value from the list and put 0 on rest of the... (9 Replies)
Discussion started by: Preeti Chandra
9 Replies
LEARN ABOUT OPENSOLARIS
print
print(1) User Commands print(1)NAME
print - shell built-in function to output characters to the screen or window
SYNOPSIS
ksh
print [-Rnprsu [n]] [arg]...
ksh93
print [-Renprs] [-f format] [-u fd] [string...]
DESCRIPTION
ksh
The shell output mechanism. When no options are specified, or when an option followed by ' a - is specified, or when just - is specified,
the arguments are printed on standard output as described by echo(1).
ksh93
By default, print writes each string operand to standard output and appends a NEWLINE character.
Unless, the -r, -R, or -f option is speciifed, each character in each string operand is processed specially as follows:
a Alert character.
Backspace character.
c Terminate output without appending NEWLINE. The remaining string operands are ignored.
E Escape character (ASCII octal 033).
f FORM FEED character.
NEWLINE character.
Tab character.
v Vertical tab character.
\ Backslash character.
x The 8-bit character whose ASCII code is the 1-, 2-, or 3-digit octal number x.
OPTIONS
ksh
The following options are supported by ksh:
-n Suppresses new-line from being added to the output.
-r-R Raw mode. Ignore the escape conventions of echo. The -R option prints all subsequent arguments and options other than -n.
-p Cause the arguments to be written onto the pipe of the process spawned with |& instead of standard output.
-s Cause the arguments to be written onto the history file instead of standard output.
-u [ n ] Specify a one digit file descriptor unit number n on which the output is placed. The default is 1.
ksh93
The following options are supported by ksh93:
-e Unless -f is specified, process sequences in each string operand as described above. This is the default behavior.
If both -e and -r are specified, the last one specified is the one that is used.
-f format Write the string arguments using the format string format and do not append a NEWLINE. See printf(1) for details on how to
specify format.
When the -f option is specified and there are more string operands than format specifiers, the format string is reprocessed
from the beginning. If there are fewer string operands than format specifiers, then outputting ends at the first unneeded for-
mat specifier.
-n Do not append a NEWLINE character to the output.
-p Write to the current co-process instead of standard output.
-r Do not process sequences in each string operand as described above.
-R
If both -e and -r are specified, the last one specified is the one that is used.
-s Write the output as an entry in the shell history file instead of standard output.
-u fd Write to file descriptor number fd instead of standard output. The default value is 1.
EXIT STATUS
The following exit values are returned:
0 Successful completion.
>0 Output file is not open for writing.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO echo(1), ksh(1), ksh93(1), printf(1), attributes(5)SunOS 5.11 27 Mar 2008 print(1)