ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
im taking a unix course in school right now. My first project seems simple enough. take all files in the current directory that are 30+ days old and tar them. Im still a little hazy on my scripting options though. I've written very simple scripts with a .c extension, a .pl extension, some with no extension, etc. I guess im wondering, is there a language I should be using to write my own scripts? If a file has a .c extension, is that just like a C programming file? All the standard C syntax. Never done perl, but I assume Perl would be a good way to go. Are there any websites that deal with writing your own scripts in Unix that you guys recommend?
Originally posted by Rv5 im taking a unix course in school right now. My first project seems simple enough. take all files in the current directory that are 30+ days old and tar them. Im still a little hazy on my scripting options though. I've written very simple scripts with a .c extension, a .pl extension, some with no extension, etc. I guess im wondering, is there a language I should be using to write my own scripts? If a file has a .c extension, is that just like a C programming file? All the standard C syntax. Never done perl, but I assume Perl would be a good way to go. Are there any websites that deal with writing your own scripts in Unix that you guys recommend?
Thanks
Hmmm... IMHO perl would be overkill for this task... something like:
Code:
#!/bin/sh
find $1 -daystart -maxdepth 1 -type f -ctime +30 -print | tar -cvTf - $2
That script would tar up all of the files in the directory named in the first argument that were over 30 days old. The
second argument to the script would be the tar file name. To process the entire tree, remove the -maxdepth 1.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.