|
|
Sponsor |
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, Eric Pement |
|---|---|
| Next by Date: | can sed take take several line to produce multiple output, shamrul ismawi |
| Previous by Thread: | Re: Simple Conditional execution in a script, YogS |
| Next by Thread: | sed users on frappr, Sven Guckes |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |
Home | sitemap
| advertise | OSDir is
an inevitable website.
|