Skip to content

Instantly share code, notes, and snippets.

@indywidualny
Created November 9, 2016 19:36
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 indywidualny/f46e7920973fbd8255a235018710ff12 to your computer and use it in GitHub Desktop.
Save indywidualny/f46e7920973fbd8255a235018710ff12 to your computer and use it in GitHub Desktop.
When run by user everything is ok, when run through cron either line_first and line_last are empty
#!/bin/bash
STATUS_DIR=~/status
# save (to file) paths to all the files in STATUS_DIR directory
ls -d -1 $STATUS_DIR/*.* > "$STATUS_DIR/files"
# read (from file) paths one by one and process the files
while read -r line
do
line_first=$(head -n 1 "$line")
line_last=$(tail -n 1 "$line")
echo "$line_first"
echo "$line_last"
done < "$STATUS_DIR/files"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment