bash - what does -s option mean in GNU sed? -


i have read sed manual -s option. there says:

-s --separate default, sed consider files specified on command line single continuous long stream. gnu sed extension allows user consider them separate files: range addresses (such ‘/abc/,/def/’) not allowed span several files, line numbers relative start of each file, $ refers last line of each file, , files invoked r commands rewound @ start of each file.

add -s , no -s in same

[root@kvm ~]# cat 1 |sed -s   -n '/1/p' 12345a6789a99999a 12345a6789a99999b  [root@kvm ~]# cat 1 |sed     -n '/1/p' 12345a6789a99999a 12345a6789a99999b  1 file  cat 1 12345a6789a99999a 12345a6789a99999b 

how use -s ?

it matters if give sed multiple files.

if don't specify -s flag, sed act if files contents had been concatenated in single stream :

echo "123 456 789" > file1 echo "abc def ghi" > file2  # input files considered single stream of 6 lines, second fourth printed sed -n '2,4 p' file1 file2   456    # stream 1, line 2 789    # stream 1, line 3 abc    # stream 1, line 4   # there 2 distinct streams of 3 lines 2nd , 3rd of each printed sed -ns '2,4 p' file1 file2  456    # stream 1, line 2 789    # stream 1, line 3 def    # stream 2, line 2 ghi    # stream 2, line 3 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -