Re: Copy a file one hundred times

2008-12-22 Thread Jörg-Volker Peetz
Tzafrir Cohen wrote:
 On Sun, Dec 21, 2008 at 04:45:21PM -0600, Ron Johnson wrote:
 On 12/21/08 15:58, Jörg-Volker Peetz wrote:
 $ seq -w 1 1 10 | xargs -i -n1 cp file.jpg file{}.jpg
 What's with the {}?  An implied variable?
 
 $ LANG=C man xargs | grep -C 2 '{}'
-i[replace-str]
   This  option  is  a  synonym for -Ireplace-str if replace-str is
   specified, and for -I{} otherwise.  This option  is  deprecated;
   use -I instead.
 

yes, {} was the default placeholder in the xargs command. According to the
man-page it should now be

$ seq -w 1 1 100 | xargs -I{} cp file.jpg file{}.jpg

-- 
Regards,
Jörg-Volker.


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Re: Copy a file one hundred times

2008-12-21 Thread Jörg-Volker Peetz
Osamu Aoki wrote:
 On Sat, Dec 13, 2008 at 09:13:07PM +, Tzafrir Cohen wrote:
 On Sun, Dec 14, 2008 at 03:50:31AM +0900, Osamu Aoki wrote:
 On Sat, Dec 13, 2008 at 07:12:32PM +, Rodolfo Medina wrote:
 I need the right syntax to copy file.jpg 100 times with one command so to 
 get
 100 files named file1.jpg, file2.jpg, ..., file100.jpg.

 Can anybody suggest how to achieve that?

 ere is one without looping :-)
snip
 $ seq 1 100 | sed s/^\(.*\)$/file\1.jpg/ |xargs -n1 cp file.jpg
 

And even shorter:

$ seq -w 1 1 10 | xargs -i -n1 cp file.jpg file{}.jpg

-- 
Regards,
Jörg-Volker.


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Re: Copy a file one hundred times

2008-12-21 Thread Ron Johnson

On 12/21/08 15:58, Jörg-Volker Peetz wrote:

Osamu Aoki wrote:

On Sat, Dec 13, 2008 at 09:13:07PM +, Tzafrir Cohen wrote:

On Sun, Dec 14, 2008 at 03:50:31AM +0900, Osamu Aoki wrote:

On Sat, Dec 13, 2008 at 07:12:32PM +, Rodolfo Medina wrote:

I need the right syntax to copy file.jpg 100 times with one command so to get
100 files named file1.jpg, file2.jpg, ..., file100.jpg.

Can anybody suggest how to achieve that?

ere is one without looping :-)

snip

$ seq 1 100 | sed s/^\(.*\)$/file\1.jpg/ |xargs -n1 cp file.jpg



And even shorter:

$ seq -w 1 1 10 | xargs -i -n1 cp file.jpg file{}.jpg


What's with the {}?  An implied variable?

--
Ron Johnson, Jr.
Jefferson LA  USA

I like my women like I like my coffee - purchased at above-market
rates from eco-friendly organic farming cooperatives in Latin America.


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org




Re: Copy a file one hundred times

2008-12-21 Thread Tzafrir Cohen
On Sun, Dec 21, 2008 at 04:45:21PM -0600, Ron Johnson wrote:
 On 12/21/08 15:58, Jörg-Volker Peetz wrote:
 $ seq -w 1 1 10 | xargs -i -n1 cp file.jpg file{}.jpg

 What's with the {}?  An implied variable?

$ LANG=C man xargs | grep -C 2 '{}'
   -i[replace-str]
  This  option  is  a  synonym for -Ireplace-str if replace-str is
  specified, and for -I{} otherwise.  This option  is  deprecated;
  use -I instead.

--
   example:

   somecommand | xargs -s 5 echo | xargs -I '{}' -s 10 rm '{}'

   Here, the first invocation of xargs has no input line length limit  be-

-- 
Tzafrir Cohen | tzaf...@jabber.org | VIM is
http://tzafrir.org.il || a Mutt's
tzaf...@cohens.org.il ||  best
ICQ# 16849754 || friend


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Re: Copy a file one hundred times

2008-12-21 Thread Slim Joe
2008/12/14, Rodolfo Medina rodolfo.med...@gmail.com:
 I need the right syntax to copy file.jpg 100 times with one command so to
 get
 100 files named file1.jpg, file2.jpg, ..., file100.jpg.

 Can anybody suggest how to achieve that?

You could try something like:

cat file.pdf | tee `seq -w 0 100 | sed 's+.*+file_.pdf+'`  /dev/null

(1) The cat command pipes the contents of the file file.pdf
to the command tee which can dump the contents of the file
to both a file (or files) and to stdout.

(2) The `seq -w [...]` creates the file names.

(3) The  /dev/null is necessary unless you want the contents of
the file to pollute your screen.


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Re: Copy a file one hundred times

2008-12-13 Thread Rick Pasotto
On Sat, Dec 13, 2008 at 07:12:32PM +, Rodolfo Medina wrote:
 I need the right syntax to copy file.jpg 100 times with one command so to get
 100 files named file1.jpg, file2.jpg, ..., file100.jpg.
 
 Can anybody suggest how to achieve that?

c=0; while [ $c -lt 100 ]; do c=$[c + 1]; n='000'$c; cp file.jpg file${n: 
-3}.jpg; done

-- 
Never compromise principle, not even on special occasions.
--- Robert Bitzer (quoted by Marcia Pearce;
quoted in Diane Dreher 1996
_The Tao of Personal Leadership_ pg 221)
Rick Pasottor...@niof.nethttp://www.niof.net


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Re: Copy a file one hundred times

2008-12-13 Thread Manon Metten
Hi Rodolfo

On Sat, Dec 13, 2008 at 8:12 PM, Rodolfo Medina
rodolfo.med...@gmail.com wrote:

 I need the right syntax to copy file.jpg 100 times with one command so to get
 100 files named file1.jpg, file2.jpg, ..., file100.jpg.


#!/bin/bash

for x in `seq 1 100`; do

if [[ x -lt  10 ]]; then cp file.jpg file-00$x.jpg;

  elif [[ x -lt 100 ]]; then cp file.jpg file-0$x.jpg;

  else cp file.jpg file-$x.jpg;

  fi

done


Greetings, Manon.


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Re: Copy a file one hundred times

2008-12-13 Thread Rick Pasotto
On Sat, Dec 13, 2008 at 07:35:44PM +0100, Manon Metten wrote:
 Hi Rodolfo
 
 On Sat, Dec 13, 2008 at 8:12 PM, Rodolfo Medina
 rodolfo.med...@gmail.com wrote:
 
  I need the right syntax to copy file.jpg 100 times with one command so to 
  get
  100 files named file1.jpg, file2.jpg, ..., file100.jpg.
 
 
 #!/bin/bash
 
 for x in `seq 1 100`; do
 
 if [[ x -lt  10 ]]; then cp file.jpg file-00$x.jpg;
 
   elif [[ x -lt 100 ]]; then cp file.jpg file-0$x.jpg;
 
   else cp file.jpg file-$x.jpg;
 
   fi
 
 done

I forgot about seq. This is even better (the -w left pads with zero for
equal width):

for x in $(seq -w 1 100); do cp file.jpg file${c}.jpg; done

-- 
Faith is often the boast of the man who is too lazy to investigate.
-- F.M. Knowles
Rick Pasottor...@niof.nethttp://www.niof.net


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Re: Copy a file one hundred times

2008-12-13 Thread John Hasler
Rodolfo writes:
 I need the right syntax to copy file.jpg 100 times with one command so to
 get 100 files named file1.jpg, file2.jpg, ..., file100.jpg.

for I in {1..100}; do cp file.jpg file$I.jpg ; done

But what are you actually trying to achieve?
-- 
John Hasler


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Re: Copy a file one hundred times

2008-12-13 Thread Osamu Aoki
On Sat, Dec 13, 2008 at 07:12:32PM +, Rodolfo Medina wrote:
 I need the right syntax to copy file.jpg 100 times with one command so to get
 100 files named file1.jpg, file2.jpg, ..., file100.jpg.
 
 Can anybody suggest how to achieve that?

ere is one without looping :-)

$ seq 1 100 | sed s/^\(.*\)$/file\1.jpg/ |xargs -n1 echo file.jpg


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Re: Copy a file one hundred times

2008-12-13 Thread Thomas Preud'homme
The Saturday 13 December 2008 20:12:32 Rodolfo Medina, you wrote :
 I need the right syntax to copy file.jpg 100 times with one command so to
 get 100 files named file1.jpg, file2.jpg, ..., file100.jpg.

 Can anybody suggest how to achieve that?

 Thanks for any reply
 Rodolfo


filevar=file.jpg
basefile=${filevar%.[^.]*}
extension=${filevar##^.*.}
for i in `seq 100`
do
  cp $filevar $basefile$i.$extension
done

with file the file to copy, basefile the file without the last extension and 
extension the last extension (without the dot).

In a function it would be

function hundred-copy ()
{
 filevar=$1 # The file to copy a hundred time
 basefile=${filevar%.[^.]*} # We delete all the end from the last dot (eg 
a dot followed by any others caracters)
 extension=${filevar##^.*.} # We delete all the beginning until the last 
dot included (biggest prefix with any caracters followed by a dot)
 do
cp $filevar $basefile$i.$extension # file become 
filenumber.extension
 done
}

Regards,

Thomas Preud'homme

-- 
Why debian : http://www.debian.org/intro/why_debian


signature.asc
Description: This is a digitally signed message part.


Re: Copy a file one hundred times

2008-12-13 Thread Tzafrir Cohen
On Sun, Dec 14, 2008 at 03:50:31AM +0900, Osamu Aoki wrote:
 On Sat, Dec 13, 2008 at 07:12:32PM +, Rodolfo Medina wrote:
  I need the right syntax to copy file.jpg 100 times with one command so to 
  get
  100 files named file1.jpg, file2.jpg, ..., file100.jpg.
  
  Can anybody suggest how to achieve that?
 
 ere is one without looping :-)
 
 $ seq 1 100 | sed s/^\(.*\)$/file\1.jpg/ |xargs -n1 echo file.jpg

err.. does this work?

-- 
Tzafrir Cohen | tzaf...@jabber.org | VIM is
http://tzafrir.org.il || a Mutt's
tzaf...@cohens.org.il ||  best
ICQ# 16849754 || friend


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Re: Copy a file one hundred times

2008-12-13 Thread Alex Samad
On Sat, Dec 13, 2008 at 09:13:07PM +, Tzafrir Cohen wrote:
 On Sun, Dec 14, 2008 at 03:50:31AM +0900, Osamu Aoki wrote:
  On Sat, Dec 13, 2008 at 07:12:32PM +, Rodolfo Medina wrote:
   I need the right syntax to copy file.jpg 100 times with one command so to 
   get
   100 files named file1.jpg, file2.jpg, ..., file100.jpg.
   
   Can anybody suggest how to achieve that?
  
  ere is one without looping :-)
  
  $ seq 1 100 | sed s/^\(.*\)$/file\1.jpg/ |xargs -n1 echo file.jpg
 
 err.. does this work?

I think he put an echo to show the lines 

echo file.jpg file1.jpg



 
 -- 
 Tzafrir Cohen | tzaf...@jabber.org | VIM is
 http://tzafrir.org.il || a Mutt's
 tzaf...@cohens.org.il ||  best
 ICQ# 16849754 || friend
 
 
 -- 
 To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
 with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
 
 

-- 
President Musharraf, he's still tight with us on the war against terror, and 
that's what I appreciate. He's a -- he understands that we've got to keep Al 
Qaeda on the run, and that by keeping him on the run, it's more likely we will 
bring him to justice.

- George W. Bush
08/22/2002
Ruch, OR


signature.asc
Description: Digital signature


Re: Copy a file one hundred times

2008-12-13 Thread Manon Metten
Hi Rick,

On Sat, Dec 13, 2008 at 7:41 PM, Rick Pasotto r...@niof.net wrote:

 I forgot about seq. This is even better (the -w left pads with zero for
 equal width):

 for x in $(seq -w 1 100); do cp file.jpg file${c}.jpg; done


Waw! Great one-liner.

BTW:  Guess you meant file${x}.jpg;

Greetings, Manon.


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Re: Copy a file one hundred times

2008-12-13 Thread Osamu Aoki
On Sat, Dec 13, 2008 at 09:13:07PM +, Tzafrir Cohen wrote:
 On Sun, Dec 14, 2008 at 03:50:31AM +0900, Osamu Aoki wrote:
  On Sat, Dec 13, 2008 at 07:12:32PM +, Rodolfo Medina wrote:
   I need the right syntax to copy file.jpg 100 times with one command so to 
   get
   100 files named file1.jpg, file2.jpg, ..., file100.jpg.
   
   Can anybody suggest how to achieve that?
  
  ere is one without looping :-)
  
  $ seq 1 100 | sed s/^\(.*\)$/file\1.jpg/ |xargs -n1 echo file.jpg
 
 err.. does this work?

THIS DOES NOT WORK! Agh...

This was my local test script :-) s/echo/cp/ is needed as you may have
guessed.

$ seq 1 100 | sed s/^\(.*\)$/file\1.jpg/ |xargs -n1 cp file.jpg

This is one should do 
 cp file.jpg file1.jpg
 cp file.jpg file2.jpg
...
 cp file.jpg file100.jpg

Osamu


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Re: Copy a file one hundred times

2008-12-13 Thread H.S.
Rick Pasotto wrote:

 
 I forgot about seq. This is even better (the -w left pads with zero for
 equal width):
 
 for x in $(seq -w 1 100); do cp file.jpg file${x}.jpg; done
 

   correction^

Nice! Something I have been looking for quite some time. I was using the
elseif statements before I saw this.

Thanks a ton.
-- 

Please reply to this list only. I read this list on its corresponding
newsgroup on gmane.org. Replies sent to my email address are just
filtered to a folder in my mailbox and get periodically deleted without
ever having been read.


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Re: Copy a file one hundred times

2008-12-13 Thread H.S.
Thomas Preud'homme wrote:
 The Saturday 13 December 2008 20:12:32 Rodolfo Medina, you wrote :
 I need the right syntax to copy file.jpg 100 times with one command so to
 get 100 files named file1.jpg, file2.jpg, ..., file100.jpg.

 Can anybody suggest how to achieve that?

 Thanks for any reply
 Rodolfo
 
 
 filevar=file.jpg
 basefile=${filevar%.[^.]*}
 extension=${filevar##^.*.}
 for i in `seq 100`
 do
   cp $filevar $basefile$i.$extension
 done
 
 with file the file to copy, basefile the file without the last extension and 
 extension the last extension (without the dot).
 
 In a function it would be
 
 function hundred-copy ()
 {
  filevar=$1 # The file to copy a hundred time
  basefile=${filevar%.[^.]*} # We delete all the end from the last dot (eg 
 a dot followed by any others caracters)
  extension=${filevar##^.*.} # We delete all the beginning until the last 
 dot included (biggest prefix with any caracters followed by a dot)
  do
 cp $filevar $basefile$i.$extension # file become 
 filenumber.extension
  done
 }
 
 Regards,
 
 Thomas Preud'homme
 


Nice job of pattern matching and extraction without using sed! Gives me
a new tool to create new filesname based on input files. Usually I run
an experiment which takes filenames as input and produces multiple files
for each file to save results in.

Thanks.

-- 

Please reply to this list only. I read this list on its corresponding
newsgroup on gmane.org. Replies sent to my email address are just
filtered to a folder in my mailbox and get periodically deleted without
ever having been read.


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Re: Copy a file one hundred times

2008-12-13 Thread H.S.
Thomas Preud'homme wrote:

  filevar=$1 # The file to copy a hundred time
  basefile=${filevar%.[^.]*} # We delete all the end from the last dot (eg 
 a dot followed by any others caracters)
  extension=${filevar##^.*.} # We delete all the beginning until the last 


Just for reference, this pattern matching and chopping is explained more
with examples here:
http://www.ibm.com/developerworks/library/l-bash.html#N1010B


-- 

Please reply to this list only. I read this list on its corresponding
newsgroup on gmane.org. Replies sent to my email address are just
filtered to a folder in my mailbox and get periodically deleted without
ever having been read.


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org