LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-05-2004, 08:00 PM   #1
Rv5
Member
 
Registered: Sep 2003
Distribution: RedHat9
Posts: 114

Rep: Reputation: 15
Scripting in Linux


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
 
Old 09-05-2004, 08:17 PM   #2
ludeKing
Member
 
Registered: Jul 2003
Location: NSW. Australia
Distribution: Ubuntu, Fedora, Slackware
Posts: 181

Rep: Reputation: 30
Perl is good, but for tasks such as these, shell scripts are good too.

ie #!/bin/sh
 
Old 09-05-2004, 10:14 PM   #3
zipster
LQ Newbie
 
Registered: Sep 2004
Posts: 2

Rep: Reputation: 0
Re: Scripting in Linux

Quote:
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.

God Bless!

Zipster
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
linux scripting desheikh Linux - General 2 10-05-2005 05:45 AM
linux scripting help anirudh Programming 6 03-04-2005 10:33 PM
Linux scripting Cybercool Linux - Newbie 5 04-16-2004 01:57 AM
Linux Scripting SainT1337 Linux - General 3 11-30-2003 01:12 PM
Linux Scripting atlight Linux - General 3 10-29-2003 08:11 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration