Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brendandawes/4bd2aad4eba1c49041c5b76270d9cb6a to your computer and use it in GitHub Desktop.
Save brendandawes/4bd2aad4eba1c49041c5b76270d9cb6a to your computer and use it in GitHub Desktop.
FIRST=
for FILE in *.csv
do
exec 5<"$FILE" # Open file
read LINE <&5 # Read first line
[ -z "$FIRST" ] && echo "$LINE" # Print it only from first file
FIRST="no"
cat <&5 # Print the rest directly to standard output
exec 5<&- # Close file
# Redirect stdout for this section into file.out
done > file.out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment