I'm trying to compare the output of the command
`ls -l directory`
with a file that I've created using the same command. (I'm trying a poor man's way of making sure no files have been modified.)
The trouble is, I don't know how to diff
the output of the ls
command with the file that I've created. I've tried the following and each time it doesn't work
diff file.ls <(ls -l directory)
ls -l directory | xargs diff file.ls
ls -l directory | diff file.ls
diff file.ls < `ls -l directory`
What is the magic command to compare the output of ls
to a file that I've already saved?
The answer (for posterity) is to do the following
diff file.ls <(ls -l directory)
When I did this previously, the output was blank. I thought I had done it wrong; in actuality there was no difference between the contents of the directory and my file.
<\\facepalm>
diff
is easiest when you compare files.
$ ls $DIR > original.ls
do some stuff
$ ls $DIR > new.ls
$ diff original.ls new.ls
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.