pogba123 pogba123 - 25 days ago 8
Bash Question

how do i use the "head" command in unix for a specified directory?

I am making a bash script command. At the moment the head command only displays the first "x number" of lines for all the files in the current directory.

How do i get it to display the "x number" of lines of all files in a different specified directory. So without me having to cd into a different directory.

Answer
head "path_to_dir"/* -n x

where:

head is the command in question

"path_to_dir"/* passes head "all files in dir"

-n x tells head to return the first x lines of each file it encounters