Skip to content

Instantly share code, notes, and snippets.

@thefiend
Last active September 29, 2018 08:34
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 thefiend/4eee708af8e18a9c40ffba24420fe6ca to your computer and use it in GitHub Desktop.
Save thefiend/4eee708af8e18a9c40ffba24420fe6ca to your computer and use it in GitHub Desktop.
Bash script to copy first line from all the text files in the current folder and save it as results.txt
#!/usr/bin/env bash
#
# Bash script to copy first line from all the text files
# in the current folder and save it as results.txt
#
rm results.txt; ls *.txt | xargs -I {} head -1 {} >> results.txt
echo "===== Results =====";
cat results.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment