0

I have multiple text files stored in a directory. My goal is to output the last non empty line (in excel) + the file name.

I have a shell file (script.sh). That implements the following code:

filename=$1
sed '/^\s*$/d'
echo $filename `tail -1 $filename`

I have tried the following:

find . -name '*.txt' -exec bash ./script.sh {} \; | xargs -L1 |
code_noob
  • 25
  • 1
  • 4
  • Pipe to `sed '/^\s*$/d'` to remove blank lines then get last line with `tail -n1`? – pawamoy Jun 07 '16 at 12:46
  • Tried it. Still no output. – code_noob Jun 07 '16 at 13:50
  • `sed '/^\s*$/d' TEST_FILE.txt | tail -n1` works great in my terminal. If you put it in `script.sh` with "$1" instead of TEST_FILE.txt then `find . -type f -name "*.txt" -exec bash ./script.sh {} \;` works great too :/ – pawamoy Jun 07 '16 at 15:24

0 Answers0