<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: mv on multiple file with joker in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383332#M35686</link>
    <description>&lt;!--!*#--&gt;&amp;gt; This works with single quote ....&lt;BR /&gt;&lt;BR /&gt;Because you're quoting only tiny parts of&lt;BR /&gt;the command:&lt;BR /&gt;      's/'&lt;BR /&gt;      '/'&lt;BR /&gt;      '/g'&lt;BR /&gt;&lt;BR /&gt;Not much point in that.  The hazards are in&lt;BR /&gt;the other parts.</description>
    <pubDate>Thu, 19 Mar 2009 18:47:08 GMT</pubDate>
    <dc:creator>Steven Schweda</dc:creator>
    <dc:date>2009-03-19T18:47:08Z</dc:date>
    <item>
      <title>mv on multiple file with joker</title>
      <link>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383324#M35678</link>
      <description>Hi Guys&lt;BR /&gt;&lt;BR /&gt;Here 400 files like this:&lt;BR /&gt;&lt;BR /&gt;ls *precl*&lt;BR /&gt;aa.precl.test    &lt;BR /&gt;aaprecl.start    &lt;BR /&gt;precl.bb&lt;BR /&gt;rrpreclyy.start&lt;BR /&gt;....&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I need to rename all this file as this:&lt;BR /&gt;aa.prect.test    &lt;BR /&gt;aaprect.start    &lt;BR /&gt;prect.bb&lt;BR /&gt;rrprectyy.start&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;What is the best way ? Of course the naive command below&lt;BR /&gt;mv *prect* *prect* &lt;BR /&gt;doesn't work naturally. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;Den</description>
      <pubDate>Thu, 19 Mar 2009 11:49:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383324#M35678</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2009-03-19T11:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: mv on multiple file with joker</title>
      <link>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383325#M35679</link>
      <description>You can use:&lt;BR /&gt;&lt;BR /&gt;for FILE in $(ls); do NEWFILE=$(echo $FILE| sed 's/precl/prect/g'); mv $FILE $NEWFILE ; done</description>
      <pubDate>Thu, 19 Mar 2009 12:17:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383325#M35679</guid>
      <dc:creator>Ivan Ferreira</dc:creator>
      <dc:date>2009-03-19T12:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: mv on multiple file with joker</title>
      <link>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383326#M35680</link>
      <description>Thank you very much Ivan. &lt;BR /&gt;I Don't close this thread immediately in case of some other callback !&lt;BR /&gt;&lt;BR /&gt;Bests Regards&lt;BR /&gt;Den</description>
      <pubDate>Thu, 19 Mar 2009 12:40:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383326#M35680</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2009-03-19T12:40:37Z</dc:date>
    </item>
    <item>
      <title>Re: mv on multiple file with joker</title>
      <link>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383327#M35681</link>
      <description>Ho to use environment variable with sed like this&lt;BR /&gt;&lt;BR /&gt;MYSOURCE=prect&lt;BR /&gt;MYDEST=precl&lt;BR /&gt;for FILE in $(ls *$MYSOURCE*); do NEWFILE=$(echo $FILE| sed 's/$MYSOURCE/$MYDEST/g'); mv $FILE $NEWFILE ; done&lt;BR /&gt;&lt;BR /&gt;Bests Regards&lt;BR /&gt;Den</description>
      <pubDate>Thu, 19 Mar 2009 12:44:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383327#M35681</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2009-03-19T12:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: mv on multiple file with joker</title>
      <link>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383328#M35682</link>
      <description>&lt;!--!*#--&gt;&amp;gt; for FILE in $(ls); [...]&lt;BR /&gt;&lt;BR /&gt;Or, if "$(ls)" causes problems, start with&lt;BR /&gt;"find", and do something similar.&lt;BR /&gt;&lt;BR /&gt;bash$ ls -l&lt;BR /&gt;total 1&lt;BR /&gt;-rw-r-----   1 SMS      40              5 Mar 19 08:41 a b&lt;BR /&gt;-rw-r-----   1 SMS      40              5 Mar 19 08:41 c d&lt;BR /&gt;bash$ for file in $(ls) ; do echo $file ; done&lt;BR /&gt;a&lt;BR /&gt;b&lt;BR /&gt;c&lt;BR /&gt;d&lt;BR /&gt;bash$&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;bash$ find . -type f&lt;BR /&gt;./a b&lt;BR /&gt;./c d&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;"$(ls)" could also make the command line too&lt;BR /&gt;long.</description>
      <pubDate>Thu, 19 Mar 2009 12:47:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383328#M35682</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2009-03-19T12:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: mv on multiple file with joker</title>
      <link>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383329#M35683</link>
      <description>About Environment variable, this seems do the job:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;MYSOURCE=prect&lt;BR /&gt;MYDEST=precl&lt;BR /&gt;for FILE in $(ls *$MYSOURCE*); do NEWFILE=$(echo $FILE| sed 's/'$MYSOURCE'/'$MYDEST'/g'); mv $FILE $NEWFILE ; done&lt;BR /&gt;&lt;BR /&gt;Any comment ? except the find insteaf of ls command.&lt;BR /&gt;&lt;BR /&gt;Bests Regards&lt;BR /&gt;Den</description>
      <pubDate>Thu, 19 Mar 2009 12:57:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383329#M35683</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2009-03-19T12:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: mv on multiple file with joker</title>
      <link>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383330#M35684</link>
      <description>Single quotes in your sed command probably won't expand the environment variables. Use double quote instead.</description>
      <pubDate>Thu, 19 Mar 2009 12:58:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383330#M35684</guid>
      <dc:creator>Ivan Ferreira</dc:creator>
      <dc:date>2009-03-19T12:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: mv on multiple file with joker</title>
      <link>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383331#M35685</link>
      <description>This works with single quote ....</description>
      <pubDate>Thu, 19 Mar 2009 13:18:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383331#M35685</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2009-03-19T13:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: mv on multiple file with joker</title>
      <link>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383332#M35686</link>
      <description>&lt;!--!*#--&gt;&amp;gt; This works with single quote ....&lt;BR /&gt;&lt;BR /&gt;Because you're quoting only tiny parts of&lt;BR /&gt;the command:&lt;BR /&gt;      's/'&lt;BR /&gt;      '/'&lt;BR /&gt;      '/g'&lt;BR /&gt;&lt;BR /&gt;Not much point in that.  The hazards are in&lt;BR /&gt;the other parts.</description>
      <pubDate>Thu, 19 Mar 2009 18:47:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383332#M35686</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2009-03-19T18:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: mv on multiple file with joker</title>
      <link>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383333#M35687</link>
      <description>and what about simple:&lt;BR /&gt;&lt;BR /&gt;rename precl prect *&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;emha.</description>
      <pubDate>Fri, 20 Mar 2009 06:26:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383333#M35687</guid>
      <dc:creator>emha_1</dc:creator>
      <dc:date>2009-03-20T06:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: mv on multiple file with joker</title>
      <link>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383334#M35688</link>
      <description>&amp;gt;This works with single quote&lt;BR /&gt;&lt;BR /&gt;Yes, you can stutter your quotes like that but it is hard to read.  If you can use double quotes, do so.&lt;BR /&gt;Of course if you use double quotes and have to use lots of backslashes, that is also hard to read.</description>
      <pubDate>Fri, 20 Mar 2009 21:43:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383334#M35688</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-03-20T21:43:41Z</dc:date>
    </item>
    <item>
      <title>Re: mv on multiple file with joker</title>
      <link>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383335#M35689</link>
      <description>There's no need to invoke sed.  If one can assume that neither prefix nor suffix matches "precl", in a bash shell you can&lt;BR /&gt;&lt;BR /&gt;for i in *precl*; do mv "$i" "${i%%precl*}prect${i##*precl}"; done&lt;BR /&gt;&lt;BR /&gt;Modern bash allows a very long command line length, so that probably won't hit the limit; if you're concerned that it might then you might do&lt;BR /&gt;&lt;BR /&gt;ls | grep precl | while read i; do mv "$i" "${i%%precl*}prect${i##*precl}"; done&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 22 Mar 2009 05:40:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/mv-on-multiple-file-with-joker/m-p/4383335#M35689</guid>
      <dc:creator>Stephen P. Schaefer</dc:creator>
      <dc:date>2009-03-22T05:40:56Z</dc:date>
    </item>
  </channel>
</rss>

