If you need to write a bash script that loop thru directory, then here’s the solution. While writing this bash script to loop thru directory files, i learn something more about single and double quote. So make sure you dont add any double quotes or single quotes to your path when you follow the tutorial below.
To loop thru directory files in bash shell, follow the steps below:-
Advertisements
- Save the code below as file.
FILES=(/home/username/*) for f in "${FILES[@]}" do # FNAME is the only the file name without path # FNAME=`basename $f` # $f store current file name with path echo "Processing $f file..." done
- Change “/home/username” to your own path
- Change the file permission to 700 or 755
- Execute the script and you will be able to loop thru the directory files
Related posts:
Mac RDP to Win 8.1 error - Remote Desktop Connection cannot verify the identity of the computer that...
Bootstrap 3: Responsive image align center
How to split large file into several smaller files - Linux
jQuery: disable autoscrolling to top when click on anchor
How to add Primary and Secondary DNS server - /etc/resolve.conf - Linux
Disable iTunes auto start when iPhone, iPad, or iPod is Connected
WordPress Custom Taxonomy Pagination show 404 page not found error
How to print screen in Asus Zenfone 6
Share this with your friends:-