The question is:
What command would you use to list the text files in your fileAsst directory (using a relative path)?
The previous question was:
Give a command to list the names of those text files, using an absolute path to the fileAsst directory as part of your command.
The answer was:
~/UnixCourse/fileAsst/*.txt
I was wondering how I can list the files in this directory using a relative path. I've tried several commands including:
ls ~/UnixCourse/fileAsst/*.txt|awk -F"/" '{print $NF}'
(cd ~/UnixCourse/fileAsst/*.txt && ls )
and a bunch of others.
But it keeps telling me their invalid. I know it has to be a correct answer because others have gotten past this. But right now I'm stuck and extremely frustrated =(
UPDATE:
After going to the CS lab someone helped me figure out the problem. I needed to be in a certain working directory at first, and I wasn't. After switching to that directory all I needed was the command:
../UnixCourse/fileAsst/*.txt
and that took care of it for me. Thanks to everyone that helped and I hope this helps someone else.
try:
$ cd ~/UnixCourse/fileAsst/
$ find .
as a one-liner (executing in a sub-shell)
$ (cd ~/UnixCourse/fileAsst/ && find .)
another approach
$ (cd ~/UnixCourse && ls fileAsst/*.txt
$ ls ~/UnixCourse/fileAsst/*.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With