|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hello
I have a shell scripting (bash) problem: - File One gets lines added to it every few minutes. - A shell script should copy the first line into File Two and so on until File Two has 100 lines. - Then File Three is created and the same is done there. Any ideas how I could do that? Thanks -- chlori |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Sorry if I'm wrong but I think you should simply use 'for' and 'test'
instructions (man test and you'll find useful information about). |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Saturday 19 August 2006 13:38, Velásquez, Constantin
<cvelasquez.gnu@gmail.com> wrote in alt.os.linux: > Sorry if I'm wrong but I think you should simply use 'for' and 'test' > instructions (man test and you'll find useful information about). WTF do you think you are talking about - your post doesn't give a clue. http://www.plainfaqs.org/Why_Netiquette.html -- Robert HULL Archival or publication of this article on any part of thisishull.net is without consent and is in direct breach of the Data Protection Act |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
chlori (usenet314+arto.ch) writes:
> - File One gets lines added to it every few minutes. > - A shell script should copy the first line into File Two and so on > until File Two has 100 lines. > - Then File Three is created and the same is done there. You cold use named pipe (man mkfifo): $ mkfifo sh17 then configure the app (or whatever) to write lines to that pipe and finally your shell script would look like: NUM=0 while NFS= read LINE; do read printf '%s\n' "$LINE" >file-$(($NUM / 100)) NUM=$(($NUM + 1)) done <sh17 or something similar. I hope you got the idea. -- Best regards, _ _ .o. | Liege of Serenly Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michal "mina86" Nazarewicz (o o) ooo +--<mina86*tlen.pl>--<jid:mina86*jabber.org>--ooO--(_)--Ooo-- |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
chlori enlightened us alt.os.linux - (ab)users with:
> Hello > > I have a shell scripting (bash) problem: > > - File One gets lines added to it every few minutes. > - A shell script should copy the first line into File Two > and so on until File Two has 100 lines. What do you want to do with the first line after it is copied to the 2nd file? You probably do not want to add the 1st line to file2 every second or faster. Will file1 have to hold a threshold of lines or may it be drained from the backside until empty, like a FIFO? > - Then File Three is created and the same is done there. > > Any ideas how I could do that? > What do you really want to do? -- vista policy violation: Microsoft optical mouse found penguin patterns on mousepad. Partition scan in progress to remove offending incompatible products. Reactivate MS software. Linux 2.6.17-mm1,Xorg7.1/nvidia [LinuxCounter#295241,ICQ#4918962] |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
Le Thu, 17 Aug 2006 16:54:53 +0200, chlori a écrit:
> Hello > > I have a shell scripting (bash) problem: > > - File One gets lines added to it every few minutes. > - A shell script should copy the first line into File Two > and so on until File Two has 100 lines. > - Then File Three is created and the same is done there. > > Any ideas how I could do that? How could you do what ? Wouldn't it be easier to post the exact text of this homework ? Just because, as it is described here it doesn't make much sense to me. (emphasis on me, as it 'd be that I just can't read fast english as much as I can write broken english :-) What I understand from your premices is that you'll fill a file File(N+1) with the content of the solely first line from File(N). Seems an easy way to slowly fill a disk with a numb line )Maybe the training exercise was just about that, see if you could think that the algorithm was dumb ? Or is it just you didn't post the *real* text ? Anyway, the answer to your post could be something based on : This is the file feeding part : (while true; do sleep 1 && date +%F%X >> /tmp/_numb ; done) & This is the triggering bot : (( 100 < $(wc -l /tmp/_numb | cut -d' ' -f1 ) )) && echo "CHANGEFILE" |
|
![]() |
| Outils de la discussion | |
|
|