Examples of Redirecting Output

# Redirect ls output to a file

ls >lsoutput.txt  # If lsoutput.txt already exists, it will be overwritten

# redirect ls output and append to “lsoutput.txt”

ls ./mydir >>lsoutput.txt

# Redirect input from a file to the sort command

sort -u <names.txt  #This will sort a list of names in the file names.txt in alphabetical order

# To view ls output a page at a time

ls | more  # The '|' is know as the “pipe” symbol

Engineering Network Services home page link College of Engineering home page link