sed: Remove lines

I wanted to remove the first and last lines of a text file that ends each line with a newline. This is because there are delimiters that are unnecessary to processing of the file. I suggest you use sed

Example input

File Start
Important line 1
Important line 2
File End

Command: sed '1d; $d' input_text_file

  • d - Delete this line
  • $ - Last line of file
  • 1 - First line of file
  • ; - End command and prepare for next

Now combine the inputs and send to clipboard

Command: sed '1d; $d' input_text_file | tr -d '\n' | xclip -sel clip

Details on the above piped commands are tr to remove newlines the -d '\n' and xclip to take the piped input and select and place on the clipboard -sel clip

Output: Important line 1Important line 2