Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

bash how to print the list of files in a directory ls

# Basic syntax:
ls /path/to/directory/

# Example usage 1:
ls /path/to/directory/ > output_file.txt # Write the files to an output
# Example usage 2:
ls /path/to/directory/ | grep *.txt > output_file.txt # Write the subset
# of files that match the grep search (e.g. end in .txt)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #bash #print #list #files #directory #ls
ADD COMMENT
Topic
Name
4+8 =