Question

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?

Was it helpful?

Solution

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>

OTHER TIPS

diff is easiest when you compare files.

$ ls $DIR > original.ls
do some stuff
$ ls $DIR > new.ls
$ diff original.ls new.ls
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top