logo       

Re: Simple Conditional execution in a script: msg#00018

editors.sed.user

Subject: Re: Simple Conditional execution in a script

Hi,
You can use following bash script


#!/bin/bash
# usage:script <file>

count=`cat $1`
for i in `seq 1 $count`; do
touch "${1}_${i}.bak"
done


if ur "file" contains 25,
then it would create empty file
file_1.bak ... file_25.bak

Regards
YogS
On 12/8/05, crmuser1998 <crmuser1998@xxxxxxxxx> wrote:
> Friends,
>
> We are trying to accomplish a simple conditional exeuction of a
> statement using sed or perl script,
>
> 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
>
> We have tried commands like more, head and cat to read the line into
> a variable so that we could loop that many times, but when we use
> those commands it is inserting a EOF into the variable value which
> negates our downstream use of the variable
>
> our script looks like
> cat 07122005.bat > $u
> echo $u
>
> This returns
> 25
> EOF
>
> Any suggestions?
>
> BTW, we are on a sun box(solaris)
>
>
>
>
>
> --
>
>
>
>
> ________________________________
> YAHOO! GROUPS LINKS
>
>
> Visit your group "sed-users" on the web.
>
> To unsubscribe from this group, send an email to:
> sed-users-unsubscribe@xxxxxxxxxxxxxxx
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
> ________________________________
>


[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~-->
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/KIlPFB/vlQLAA/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>
Google Custom Search

News | FAQ | advertise