Here is a small script that will get the files from the $folder variable using a dir function.
The command in a terminal is: ls (short for List). This will list the files in the current directory. Whilst in the Home directory, to list the files in a different directory, for instance Videos, use: ls Videos.
for i in * do if [ -d $i ]; then echo $i directory >> /tmp/directories fi done
DIR
To list all the files in a directory you would use the following: $handle = opendir('/path/to/folder'); while(($file = readdir($handle)) !== false){ // do things with files // you will want to filter out things like ., .., and .htaccess echo $file; } Also, to return a list of all the files in a directory, especially with wildcards, use something such as: $file_array = glob("*"); $files = implode("\n", $file_array); echo $files; will give you a list of all the files directly.
dir Lists all files and directories in the directory that you are currently in. dir /ad List only the directories in the current directory. If you need to move into one of the directories listed use the CD command. dir /s Lists the files in the directory that you are in and all sub directories after that directory, if you are at root "C:\>" and type this command this will list to you every file and directory on the C: drive of the computer. dir /p If the directory has a lot of files and you cannot read all the files as they scroll by, you can use this command and it will display all files one page at a time. dir /w If you don't need the info on the date / time and other information on the files, you can use this command to list just the files and directories going horizontally, taking as little as space needed. dir /s /w /p This would list all the files and directories in the current directory and the sub directories after that, in wide format and one page at a time. dir /on List the files in alphabetical order by the names of the files. dir /o-n List the files in reverse alphabetical order by the names of the files. dir \ /s |find "i" |more A nice command to list all directories on the hard drive, one screen page at a time, and see the number of files in each directory and the amount of space each occupies. dir > myfile.txt Takes the output of dir and re-routes it to the file myfile.txt instead of outputting it to the screen.
ls | sort -r Use ls command to list all files, in the present directory. Then pipe '|' the output of the ls command to sort -r. The -r option will reverse the sort.
Under M$ windows, "dir". Under *nix, "ls". "ls -al" will list ALL files and subdirectories (even the hidden ones which start with a '.' in a long format which is easier to read and tells you more information about the files).
In UNIX, type `grep -l computer *`. This should list the names of all files that contain the word 'computer' in alphabetical order.
"Asterix is not a command.. Its a comic character.." Actually asterix is also a so called wildcard character in MS-DOS. It replaces a whole series of characters related to file name, extension or both. For example, if you want to delete all files named "list" from a current directory (no matter what type those files are) use the following command: del list.* In case you want to delete all files with .txt extension from the current directory, use: del *.txt Or if you want to delete all files in the directory no matter what type they are or what they were called, use: del *
Programs store configuration files, caches, and other user-specific files as hidden files/folders in your home directory. To see a list of all of these files, use: $ ls -a ~ It is usually not a good idea to delete any of these files if you don't know what they are for.
ls list directory content-l long format, displaying Unix file types, permissions, number of hard links, owner, group, size, date, and file name-a lists all files in the given directory, which names begins with .-r Reverse the order of the sort.-t sort the list of files by modification time.This lists the most recently modified files at the end of the listing. ls -latr is a convenient way to see what has changed recently in a directory.
rm -rv /path/to/directory