|
Re: Simple Conditional execution in a script: msg#00025editors.sed.user
On Thu, 08 Dec 2005 11:05:17 +0800, crmuser1998 wrote: > > We are trying to read a line from a file and generate a separate set > of files based on the lines from that file, > > In most cases our source file has a number which tells us how many > files to create, so we have to read from a file called 07122005.bak, > which has just a number '25', we need to generate > 07122005_1.bak ..07122005_25.bak > gsed solution: A gun extension ('e' command) is used, so to run the following shell script correctly you have to use gnu sed. ----filenamegenerater # !/bin/bash sed 's/.*/touch `seq -f'${1}'_%g 1 &`/;e' $1 ----end invoke: ./filenamegenerater 07122005.bak As a complement, here is gawk solution (I guess this can work with other awk clone as well): gawk '{for (i=1;i<=$0;i++) printf ""> FILENAME"_"i".bak"}' 07122005.bak -- Time for bed, see you! hq00e ------------------------ Yahoo! Groups Sponsor --------------------~--> Fair play? Video games influencing politics. Click and talk back! http://us.click.yahoo.com/2jUsvC/tzNLAA/TtwFAA/dkFolB/TM --------------------------------------------------------------------~-> -- Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/sed-users/ <*> To unsubscribe from this group, send an email to: sed-users-unsubscribe@xxxxxxxxxxxxxxx <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/ |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Replacing a pattern in one file by reading a string from anotherfile: 00025, Eric Pement |
|---|---|
| Next by Date: | can sed take take several line to produce multiple output: 00025, shamrul ismawi |
| Previous by Thread: | Re: Simple Conditional execution in a scripti: 00025, YogS |
| Next by Thread: | sed users on frappr: 00025, Sven Guckes |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |