My script is saved as
recent.sh and reads currently as:
ls -t -p | grep -v / | head -n1 | cat
source recent.sh it and execute
rcnt, it prints the most recent file in the directory. However, when I
sh recent.sh it does not print anything to the Terminal. (I try to run it from the directory where it is saved.)
I am trying to run this in Terminal in Linux Mint 19 and I've already tried it with
usr/bin/env bash, without the -x, with sh instead of bash. Permissions are 777.
How to run this script so that it will print to the Terminal where I executed it?
I'm a beginner, I might be overlooking something, but I read all the relevant SO, StackExchange, etc. answers which mostly recommend setting permissions right, which I believe I have right, the location of bash (which for me is bin/bash) or other code-specific issues.