linux - How to tell shell command tail not to wait for parameter -


my current code

tail -n 1 `ls -1t /path/*.txt 2>/dev/null | head -n 1` | awk '{print $1}' 

works fine if there @ least 1 *.txt file in directory.

but if there no such file, tail waiting input , not end.

how need modify code ensure ends if no file present?

did quick test, adding /dev/null "fake" file seems trick.

tail -n 1 `ls -1t /path/*.txt 2>/dev/null | head -n 1` /dev/null | awk '{print $1}' 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -