Forrest logo
back to the sed tool

file_manipulation:warp:d071fbbca6930a159e0a53c168b52ef7

Print the nth line of a file
$ sed '${line_number}q;d' ${file_path}
try on your machine

This command is using the sed command-line tool to extract a specific line from a file.

Here's a breakdown of the command:

  • sed: The sed command-line tool is used for text manipulation and editing.
  • ${line_number}: This is a variable representing the line number you want to extract from the file.
  • q: The 'q' command tells sed to quit after processing the specified line.
  • d: The 'd' command deletes the pattern space (current line) and proceeds to the next line.

${file_path}: This is a variable representing the path to the file you want to extract the line from.

Overall, the command tells sed to print the specified line number and then exit, effectively extracting only that line from the file.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the sed tool