简体   繁体   中英

KSH script list files/directories in another place

I'm learning KSH at the momment and wondering....if you used the command:

ls .* it would display all files in that current directory including any other directories.

what if I wanted to display all the items in another directory? How would I accomplish this.

This is what I used firstly:

#!/bin/ksh

echo "Files in Folder:"
ls .*

No, ls .* will only list the hidden files and directories which by convention start with a dot. This will include .. , which will actually be listing the files in the parent directory. You can just use ls or ls * . If you want to list the contents of another directory, use ls $1 and call the script like so: script.ksh /tmp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM