DSED(1)
DSED(1) ZOAU Command Syntax DSED(1)
NAME
dsed: A command-line edit of partitioned dataset members
and sequential datasets or hfs file.
SYNOPSIS
dsed [-<h|i|v|d|s|l|f>] [-c <encoding>] [-e <command> ...] <cmd> <dataset>
-h: syntax
-e: for execute multiple sed command
-v: print verbose information
-d: print debug information in json format
-s: stop executing sed commands if current command was successful
-c: dataset encoding, default: IBM-1047
-l: obtain exclusive lock for the dataset
-f: force open. Open dataset member in DISP=SHR mode. Default is DISP=OLD mode when not provided.
DESCRIPTION
dsed 's/<regex>/<line>/g' dest #replace word (global replace)
dsed '/<regex>/c\<line>' dest #replace line global
dsed '<n> c\<line>' dest #replace nth line
dsed '/<regex>/c\<line>/<n>' dest #replace line first match n=1,last match n=$
dsed '/<regex>/a\<line>' dest #insert after(greedy match and insert)
dsed '/<regex>/i\<line>' dest #insert before(greedy match and insert)
dsed '/<regex>/a\<line>/<n>' dest #insert after(non-greedy match and insert,first match n=1,last match n=$)
dsed '/<regex>/i\<line>/<n>' dest #insert before(non-greedy match and insert,first match n=1,last match n=$)
dsed '1 i\<line>' dest #insert BOF
dsed '$ a\<line>' dest #append EOF
dsed '<n> a\<line>' dest #append to nth line
dsed '<n> i\<line>' dest #insert before nth line
dsed '/<regex>/d' dest #delete regex existed line
dsed -e <command1> -e <command2> dest #multiple sed commands
dsed -d <command> dest #modify target file, print debug information
dsed -c ISO8859-1 <command> dest #modify ASCII dataset
dsed -s -e <command1> -e <command2> dest #multiple sed commands, will not execute command2 if command1 was successful
NOTES
'#' can be used as the delimiter instead of '/'
EXAMPLES
Change all occurrences of '1st' to 'change'
dsed 's/1st/change/g' IBM.TEXT
Replace lines containing '1st' with 'this is changed'
dsed '/1st/c\\this is changed' IBM.TEXT
Replace the last line containing '1st' with 'this is changed'
dsed '/1st/c\\this is changed/$' IBM.TEXT
Insert 'this is appended' after last line containing '1st'
dsed '/1st/a\\this is appended/$' IBM.TEXT
Insert 'this is inserted' before any line containing '1st'
dsed '/1st/i\\this is inserted' IBM.TEXT
Delete any line containing '1st'
dsed '/1st/d' IBM.TEXT
Add a new line to beginning of the file
dsed '1 i\\this is an added line' IBM.TEXT
Insert a new line after the 2nd line
dsed '2 a\\this is an added line' IBM.TEXT
Change all occurrences of '1st' to 'change' ('#' as delimiter)
dsed 's#1st#change#g' IBM.TEXT
EXIT VALUES
0 dsed successfully applied the command to the dataset.
other Error occurred. See error messages for details.