pogba123 pogba123 - 1 year ago 87
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 Source
head "path_to_dir"/* -n x


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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download