0

I have a list of 7 directories. Every day they get a file. I would run one command that would check all the directories at once which provides the output of the file names.

Normally I run ls /direct1 to each of the 7 directly and honestly I tried piping all those command together but that doesn’t work either. I really don’t mind trying to figure things out on my own but I am just not sure what to search for. Most of my google results have point to scripts that would include the file names but that really seems like overkill. Maybe that's the only way and the reason for those results.

1
  • Changed comment to: Pardon my ignorance. I see what you mean. That will help after our migration. Nov 10, 2016 at 15:28

3 Answers 3

1

ls accepts more than one file/directory argument: try ls /directory1 /directory2 ... /directoryN

Edit: Also, executing several commands with independent targets after another doesn't work with pipes, but does with semicolons: ls /directory1; ls /directory2; ....

1
  • WOW. Even easier than I was trying to make it. It seems like I should have known that as I use 'mv' to move multiple files. I dont pipe those....anyway, thanks!! have a wonderful day. Nov 10, 2016 at 15:14
0

If all those 7 Directory are in the one place then please refer the comment by Christopher

ls -R

This will list all the content of the 7 directory if they are in the same location.

1
  • oh, that is why that was suggested. I think after our migration that would apply. Thanks for that suggestion. Nov 10, 2016 at 15:27
0

You can define an alias in your ~/.bashrc file:

nano ~/.bashrc

Copy and paste the alias at the end of the file

alias lsall='ls "/dir1/" "/dir2/" "/dir3/"'

Restart your terminal and type

lsall

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .