Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
A bash script that would scroll through the files in a particular directory (an arbitrary number of files, with arbitrary names, in a specified directory) would be very useful.
If someone knows how to achieve this, I would certainly appreciate your enlightenment.
Thanks,
Samer

Random?? Array?? Where does that come from? We must be reading different descriptions.
'scroll through' - what do you mean my that. I imagine that you don't mean just list the files, because that can be done with 'ls'. So, maybe you mean to display the contents of each file:# change to the desired directory (dir name is first command line parameter)
cd $1# loop thru each file in the directory
for file in `ls`
do# display the file contents
more $filedone
# change back to original directory
cd -
Make sure that you use back quotes around the ls command above

Thanks for the help. What I meant was, there are many times when one wants to do certain things, the same things to files in a directory, regardless of the names of the files, and how many files are in that directory, thats all.

Look in the Bash programmin HOW-TO, section 7.1 (http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-7.html#ss7.1) change "echo item: $i" to whatever you need. If you are installing a bunch of RPMs it would be rpm -Uvh $i, whatever. Bash interprets anything inside parentheses as a command. The cool thing is you can do this all on the command line, no need to write a script unless you do the same thing over and over.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |