-7
head -$4 $5 > temp
head -$2 $3 | tail -n +$1 >> temp
tail -n +$(expr $4 +1) $5>> temp

This is a problem using head and tail. I need a description of each line please thank!

  • 1
    Did you try to read `man head` and `man tail` before asking? – Bor Laze May 25 '17 at 23:28
  • RTFM. "Read the fine manual". eg. `man head`, `man tail` – William Pursell May 25 '17 at 23:28
  • I dont get the $4 and $5 because they refer to arguments and it is not specified( in man) – Piggy Shogun May 25 '17 at 23:29
  • $4 ans $5 are command-line arguments. The fourth ($4) had better be an integer, and the fifth ($5) had better be the name of a file. Same with $2 (integer) and $3 (file). – Jack May 25 '17 at 23:31
  • How can you be a shell programmer if you don't understand these lines? They should be explained at the very beginning of any scripting tutorial. – Barmar May 25 '17 at 23:48

1 Answers1

0

$2, $3, $4 and $5 are all command line arguments called positional parameters.

Line 1:

Reads the first n lines [represented by $4, a positional parameter] in a file [represented by $5, another positional parameter] and creates a file called "temp" with the output.

Line 2:

Reads the first n lines [represented by $2, a positional parameter] in a file [represented by $3, another positional parameter], then reads the last n lines of that command and appends the output to the "temp" file.

Line 3:

Reads the last n number of lines, where n is equal to ($4 + 1) in a file [represented by $5, yet another positional parameter] and appends the output to the "temp" file.

Jacob
  • 890
  • 6
  • 16