Manipulating Files
Last updated
Was this helpful?
Was this helpful?
# List the files in the current directory
# and print extended information
ls -l# Format the output of ls -l by removing
# cases of multiple spaces and replace
# them with a single space for easier
# parsing
ls -l | tr -s " "# Use the cut program to separate each line
# of output into colums, delimited by a space
# then print columns 3-4. In the case of this
# output, we're printing the users and groups
# which own the files in the directory
ls -l | tr -s " " | cut -d" " -f3-4# Alphabetically sort the users and groups which
# own the files in the directory
ls -l | tr -s " " | cut -d" " -f3-4 | sort# Count the instances of users and groups so we can
# know who owns files in the current directory and
# how many files they own
ls -l | tr -s " " | cut -d" " -f3-4 | sort | uniq -c