Sometimes in a terminal you want to strip out the first line of output from a command. For example, you may want to generate a list of users which have tasks running using the
ps command. This command puts a header at the top of the output. You can remove this header by piping the output to
sed 1d. This will ignore the first line and print everything else.
To see this in action, the following command will provide a list of users, in alphabetical order, who have programs running on that machine. Note the
sed 1d command – without it,
UID would also appear in the list as it is the first word in the header.
$ ps -ef | sed 1d | cut -d' ' -f1 | sort -u