<?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: using &amp;quot;for' in script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/using-quot-for-in-script/m-p/3431707#M102285</link>
    <description>Hope I can tag on this thread. I have the same issue with spaces in file names - the listed solutions work for the echo stmt but I need to work with these files using a cp or mv or rm command - and I find that the same variable that is fine in the echo statement goes to the cp stmt in pieces again. &lt;BR /&gt;&lt;BR /&gt;For example, if I get the file name into variable j, the stmt #cp /here/$j /there/$j will parse out the filename up to the first space. &lt;BR /&gt;&lt;BR /&gt;any suggestions ? &lt;BR /&gt;&lt;BR /&gt;Lisa</description>
    <pubDate>Thu, 06 Oct 2005 18:26:24 GMT</pubDate>
    <dc:creator>Lisa Sorbo</dc:creator>
    <dc:date>2005-10-06T18:26:24Z</dc:date>
    <item>
      <title>using "for' in script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-quot-for-in-script/m-p/3431702#M102280</link>
      <description>Hello, &lt;BR /&gt;&lt;BR /&gt;I have a file which contains a list of backup names, some names have spaces some don't, when using the following it appears that the names with space are treated as two.&lt;BR /&gt;&lt;BR /&gt;for i in `cat $file1 | awk -F"\t" '{print $1}'`;do&lt;BR /&gt;echo $i&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;file1 contains things like:&lt;BR /&gt;backup1 offline&lt;BR /&gt;backup2_online&lt;BR /&gt;etc...&lt;BR /&gt;&lt;BR /&gt;I am sure there is a way around this but cannot find it.&lt;BR /&gt;&lt;BR /&gt;Please help&lt;BR /&gt;Sebastien</description>
      <pubDate>Sun, 28 Nov 2004 13:10:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-quot-for-in-script/m-p/3431702#M102280</guid>
      <dc:creator>sebastien_7</dc:creator>
      <dc:date>2004-11-28T13:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: using "for' in script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-quot-for-in-script/m-p/3431703#M102281</link>
      <description>Hi,&lt;BR /&gt;try with qoutes&lt;BR /&gt;echo "$i"&lt;BR /&gt; &lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Sun, 28 Nov 2004 13:34:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-quot-for-in-script/m-p/3431703#M102281</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2004-11-28T13:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: using "for' in script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-quot-for-in-script/m-p/3431704#M102282</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;try "while" insted of "for":&lt;BR /&gt;&lt;BR /&gt;cat $file1 | while read&lt;BR /&gt;do&lt;BR /&gt;  echo ${REPLY}&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Sun, 28 Nov 2004 14:12:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-quot-for-in-script/m-p/3431704#M102282</guid>
      <dc:creator>Slawomir Gora</dc:creator>
      <dc:date>2004-11-28T14:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: using "for' in script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-quot-for-in-script/m-p/3431705#M102283</link>
      <description>thanks guys,&lt;BR /&gt;That was pretty fast, Slawomir's suggestion worked just fine using this:&lt;BR /&gt;cat $file1|awk -F"\t" '{print $1}'|while read&lt;BR /&gt;do&lt;BR /&gt;echo ${REPLY}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;thanks again&lt;BR /&gt;sebastien</description>
      <pubDate>Sun, 28 Nov 2004 14:20:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-quot-for-in-script/m-p/3431705#M102283</guid>
      <dc:creator>sebastien_7</dc:creator>
      <dc:date>2004-11-28T14:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: using "for' in script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-quot-for-in-script/m-p/3431706#M102284</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;The problem is you are in effect writing&lt;BR /&gt;&lt;BR /&gt;for i in backup1 offline backup2_online&lt;BR /&gt;do&lt;BR /&gt;...&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;So the for loop cannot differentiate (even with quotes).  You need to join them together.  Perl would probably be the tool of choice, but as you've chosed awk I'll do it like so...Try&lt;BR /&gt;&lt;BR /&gt;for i in $(cat file | awk -F"\t" '{print $1}' | sed -e "s/\ /:/g")&lt;BR /&gt;do&lt;BR /&gt;j=$(echo $i | sed "s/:/\ /g")&lt;BR /&gt;etc...&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Tim</description>
      <pubDate>Sun, 28 Nov 2004 14:27:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-quot-for-in-script/m-p/3431706#M102284</guid>
      <dc:creator>Tim D Fulford</dc:creator>
      <dc:date>2004-11-28T14:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: using "for' in script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-quot-for-in-script/m-p/3431707#M102285</link>
      <description>Hope I can tag on this thread. I have the same issue with spaces in file names - the listed solutions work for the echo stmt but I need to work with these files using a cp or mv or rm command - and I find that the same variable that is fine in the echo statement goes to the cp stmt in pieces again. &lt;BR /&gt;&lt;BR /&gt;For example, if I get the file name into variable j, the stmt #cp /here/$j /there/$j will parse out the filename up to the first space. &lt;BR /&gt;&lt;BR /&gt;any suggestions ? &lt;BR /&gt;&lt;BR /&gt;Lisa</description>
      <pubDate>Thu, 06 Oct 2005 18:26:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-quot-for-in-script/m-p/3431707#M102285</guid>
      <dc:creator>Lisa Sorbo</dc:creator>
      <dc:date>2005-10-06T18:26:24Z</dc:date>
    </item>
    <item>
      <title>Re: using "for' in script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-quot-for-in-script/m-p/3431708#M102286</link>
      <description>cp /here/$j /there/$j &lt;BR /&gt;&lt;BR /&gt;cp "/here/${j}" "/there/${j}"&lt;BR /&gt;&lt;BR /&gt;Disciplined shell programmers get into the habit of encloses all variables with {}'s and quoting as well because whitespace has always been legal (if dumb) in UNIX pathnames.</description>
      <pubDate>Thu, 06 Oct 2005 23:03:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-quot-for-in-script/m-p/3431708#M102286</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-10-06T23:03:01Z</dc:date>
    </item>
    <item>
      <title>Re: using "for' in script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-quot-for-in-script/m-p/3431709#M102287</link>
      <description>For loop will handle based on delimiters space or tab or new line also.  You have to use while loop to handle "\n" as Record seperator. It is handled by IFS variable.&lt;BR /&gt;&lt;BR /&gt;while read line;&lt;BR /&gt;do&lt;BR /&gt;  echo $line&lt;BR /&gt;done &amp;lt; &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;It is more efficient than cat file | while.&lt;BR /&gt;&lt;BR /&gt;===&lt;BR /&gt;&lt;BR /&gt;lisa,&lt;BR /&gt;&lt;BR /&gt;You can use methods as,&lt;BR /&gt;&lt;BR /&gt;touch "hi bye"&lt;BR /&gt;here hi bye is a single file name.&lt;BR /&gt;var="hi bye"&lt;BR /&gt;&lt;BR /&gt;You can move as,&lt;BR /&gt;&lt;BR /&gt;# mv "$var" hi&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;# mv ${var} hi&lt;BR /&gt;&lt;BR /&gt;hth.&lt;/FILENAME&gt;</description>
      <pubDate>Fri, 07 Oct 2005 00:28:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-quot-for-in-script/m-p/3431709#M102287</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-10-07T00:28:32Z</dc:date>
    </item>
  </channel>
</rss>

