Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
05-09-2006, 11:06 AM
|
#1
|
|
Member
Registered: Apr 2004
Location: Saskatoon SK. CA
Distribution: Ubuntu Dapper
Posts: 50
Rep:
|
Need help with bash scripting
Hey all,
I'm essentially looking for a quick-n-dirty scripting intro and then I should be good, I have coded in java, perl, c, and others but it's been a while and I've never really got into shell scripting. Essentially I'm trying to write a script to execute one command on each file in a directory. Basic file conversion at its finest, I'm just hoping I can write this script quickly before it becomes necessary to convert each file manually  Come to think of it all I really need is to tell the script to find all files of a given type in the current directory and construct a loop to go through them  Thanks for your time
Kleedrac
|
|
|
|
05-09-2006, 11:47 AM
|
#2
|
|
Senior Member
Registered: Sep 2005
Location: Russia
Distribution: NixOS (http://nixos.org)
Posts: 1,893
Rep:
|
man bash
for i in *.sh; do
cat $i;
done
Is idea clear?
|
|
|
|
05-09-2006, 11:53 AM
|
#4
|
|
Member
Registered: Apr 2004
Location: Saskatoon SK. CA
Distribution: Ubuntu Dapper
Posts: 50
Original Poster
Rep:
|
Woah ... all right ... thanks guys.
Raskin: So if I understand right if I just wanted to duplicate every file of type .sh in a directory;
for i in *.sh; do
cp $i $i.nosh
done
Is that basically it?! Man ... thanks a lot you guys ... I'll try this out when I'm done work today 
|
|
|
|
05-09-2006, 11:54 AM
|
#5
|
|
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,697
|
I found this "quick & dirty' intro to be very useful. If you've done programming before, it should be a snap for you. LinuxCommand.org
For more in-depth study, try here:
Advanced Bash Scripting Guide
|
|
|
|
05-09-2006, 11:57 AM
|
#6
|
|
Senior Member
Registered: Sep 2005
Location: Russia
Distribution: NixOS (http://nixos.org)
Posts: 1,893
Rep:
|
Yes, if you haven't .sh.nosh files it will work fine. Else it'll work fine, but destroy information. Also, if you add suffix ${i}.nosh is more predictable if some day you suffix will try to merge with variable name - that way it is delimited.
|
|
|
|
05-09-2006, 02:55 PM
|
#7
|
|
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,797
|
Bash guide for Beginners--by Machtelt Garrels (on tldp.org)
Classic shell scripting--O'Reilly Most any big bookstore or Amazon
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:54 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|