The sed script prints the first line of input and then prints a line of *
characters of exactly the same width as the first line.
1{p;s/./*/g}
1
is an address matching the first line of input only. i.e. thesed
commands in the{}
block apply only to the first line.p
- print the input without change;
is a command separator, in this case separating thep
command and thes/./*/g
command.s/./*/g
- change every character to a*
, and print the result.
Any remaining input (lines 2+) are printed unmodified if they exist as per sed
's default behaviour (if used without the -n
option)
The whole command:
column -t -s : <(echo Name:Age:Gender:Height:Weight) test.txt | sed "1{p;s/./*/g}"
uses column -t -s :
to tabulate input consisting of the echoed string "Name:Age:Gender:Height:Weight"
and the contents of file.txt
. column
's output is piped to sed
to produce the line of ******
s separating the header from the rest of the output.