LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 03-16-2006, 04:42 PM   #1
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,563
Blog Entries: 1

Rep: Reputation: 1024Reputation: 1024Reputation: 1024Reputation: 1024Reputation: 1024Reputation: 1024Reputation: 1024Reputation: 1024
simple shell script


I want to write a simple shell script which would
merge some files into one. Every day I create a new file with the stuff that I learnt or changed on my system. The files' names are eg. 10.03.06, 11.03.06, 12.03.06 etc.
In the same directory I have some other files with names containing letters (not numerals), so I wanted grep to pick
all the files with dates as names and cat to merge them in one file with the name eg. history
when I write:
cat | grep [^a-zA-Z] > history
it creates the file history, but it's empty. I mean,
know it can't work but I can't think of anything else

Ideally, later on the script would append only files
from the last week to the history file and would be
run as a weekly cron job.
thanks
 
Old 03-16-2006, 05:47 PM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
Grep searches the contents of files for patterns, not the filenames themselves, unless you are using it in a pipe to filter the output of "ls" or "find".
You could simply use globbing.

cat [[:digit:]][[:digit:]].03.06 >history

If you want to add to the end of the history file, then use ">>" instead of ">".
 
Old 03-16-2006, 06:00 PM   #3
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,563
Blog Entries: 1

Original Poster
Rep: Reputation: 1024Reputation: 1024Reputation: 1024Reputation: 1024Reputation: 1024Reputation: 1024Reputation: 1024Reputation: 1024
thanks jschiwal, that's exactly what I meant
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Simple shell script mikz Linux - General 1 02-24-2005 07:18 AM
simple shell script sharpie Programming 9 06-02-2004 11:47 PM
a simple shell script Warchief Programming 1 07-31-2003 05:01 AM
Very Simple Shell Script cli_man Linux - Software 5 04-24-2003 10:14 AM
Simple C Shell script is not so simple elconde Programming 2 09-16-2001 11:53 PM


All times are GMT -5. The time now is 05:36 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration