Apply argument to all files in directory

Hi all:

i need to run a rather simple command-line argument:

head -200 input > output

However, I need to do it on several files, all in the same directory.

Is this possible?

If you want all of them to go to the same output file, use head with a pattern that matches all the files you target. For individual output files, use a for loop with resp. pattern.

EDIT: BTW - man head is your friend!

first do an "ls" on the files in the directory which u need to check the head.

Then loop the file names

#!/bin/bash
cd input_directory
ls -ltr | awk '{print $9}' | sed '/^$/d' > result.txt
while read line
do
head -200 $line >> output_file
done < result.txt