<?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 Need Help for C shell variables assigment from file in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-c-shell-variables-assigment-from-file/m-p/3149704#M717963</link>
    <description>Hi Everyone,&lt;BR /&gt;&lt;BR /&gt;I was hoping that someone might know of a way to handle this using C shell.&lt;BR /&gt;&lt;BR /&gt;Basically I'm trying to write a csh script that will look into a directory on a hpux machine that is a samba share. I want to do a number of things to the files in this directory in a batch mode from this script.&lt;BR /&gt;&lt;BR /&gt;I first "ls" and redirect the listing to a file, I then read the file 1 line at a time and assign the files' filename to a var for use in later opperations.&lt;BR /&gt;&lt;BR /&gt;Here is my problem, this directory hold many files from windows based systems and many have spaces in their names (which the scipt can deal with) however some files have multipule spaces in a row within the filename and when the name is assigned to the var, it loses any multipule space no matter how I try to quote it or what utility I use to read the filelist I.E. sed,awk etc..&lt;BR /&gt;&lt;BR /&gt;Here is a little script that will illistrate the problem.&lt;BR /&gt;1) it will create a "test" dir under /tmp&lt;BR /&gt;2) it will touch 2 files with multipule spaces in there names.&lt;BR /&gt;3)it will then put the names into a list which&lt;BR /&gt;contains the right filenames with the spaces.&lt;BR /&gt;4) then it will try to assign 1 filename at a time from the list to a var.&lt;BR /&gt;&lt;BR /&gt;You will then see that the var has the filename but with only 1 space where there were multipules.&lt;BR /&gt;&lt;BR /&gt;Here is the scripts text&lt;BR /&gt;-------------------------&lt;BR /&gt;#!/bin/csh -f&lt;BR /&gt;cd /tmp&lt;BR /&gt;mkdir test&lt;BR /&gt;cd test&lt;BR /&gt;touch "test file with three spaces"&lt;BR /&gt;touch "test file with four spaces"&lt;BR /&gt;&lt;BR /&gt;set f_cnt = 1&lt;BR /&gt;set f_max = 0&lt;BR /&gt;ls -1A &amp;gt; /tmp/filelist&lt;BR /&gt;@ f_max = `cat /tmp/filelist | wc -l`&lt;BR /&gt;while (${f_cnt} &amp;lt;= ${f_max})&lt;BR /&gt;set src_file = `sed -n "${f_cnt}p" /tmp/filelist`&lt;BR /&gt;if (${#src_file} == 0) exit&lt;BR /&gt;set new_file = "${src_file}.new"&lt;BR /&gt;echo "names read to vars from file"&lt;BR /&gt;echo "${src_file}"&lt;BR /&gt;echo "${new_file}"&lt;BR /&gt;echo "mv command fails"&lt;BR /&gt;mv "${src_file}" "{new_file}"&lt;BR /&gt;@ f_cnt++&lt;BR /&gt;end&lt;BR /&gt;echo "names in filelist"&lt;BR /&gt;cat /tmp/filelist&lt;BR /&gt;------------------------&lt;BR /&gt;&lt;BR /&gt;HELP !!!&lt;BR /&gt;&lt;BR /&gt;If someone could please show me how to read one line at a time from a file and assign it to a var in c shell and have the var maintain the multipule spaces so that the var can then be used to "mv" "del" or whatever on the file from a script.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Rick</description>
    <pubDate>Fri, 19 Dec 2003 11:35:55 GMT</pubDate>
    <dc:creator>Rick Jones_2</dc:creator>
    <dc:date>2003-12-19T11:35:55Z</dc:date>
    <item>
      <title>Need Help for C shell variables assigment from file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-c-shell-variables-assigment-from-file/m-p/3149704#M717963</link>
      <description>Hi Everyone,&lt;BR /&gt;&lt;BR /&gt;I was hoping that someone might know of a way to handle this using C shell.&lt;BR /&gt;&lt;BR /&gt;Basically I'm trying to write a csh script that will look into a directory on a hpux machine that is a samba share. I want to do a number of things to the files in this directory in a batch mode from this script.&lt;BR /&gt;&lt;BR /&gt;I first "ls" and redirect the listing to a file, I then read the file 1 line at a time and assign the files' filename to a var for use in later opperations.&lt;BR /&gt;&lt;BR /&gt;Here is my problem, this directory hold many files from windows based systems and many have spaces in their names (which the scipt can deal with) however some files have multipule spaces in a row within the filename and when the name is assigned to the var, it loses any multipule space no matter how I try to quote it or what utility I use to read the filelist I.E. sed,awk etc..&lt;BR /&gt;&lt;BR /&gt;Here is a little script that will illistrate the problem.&lt;BR /&gt;1) it will create a "test" dir under /tmp&lt;BR /&gt;2) it will touch 2 files with multipule spaces in there names.&lt;BR /&gt;3)it will then put the names into a list which&lt;BR /&gt;contains the right filenames with the spaces.&lt;BR /&gt;4) then it will try to assign 1 filename at a time from the list to a var.&lt;BR /&gt;&lt;BR /&gt;You will then see that the var has the filename but with only 1 space where there were multipules.&lt;BR /&gt;&lt;BR /&gt;Here is the scripts text&lt;BR /&gt;-------------------------&lt;BR /&gt;#!/bin/csh -f&lt;BR /&gt;cd /tmp&lt;BR /&gt;mkdir test&lt;BR /&gt;cd test&lt;BR /&gt;touch "test file with three spaces"&lt;BR /&gt;touch "test file with four spaces"&lt;BR /&gt;&lt;BR /&gt;set f_cnt = 1&lt;BR /&gt;set f_max = 0&lt;BR /&gt;ls -1A &amp;gt; /tmp/filelist&lt;BR /&gt;@ f_max = `cat /tmp/filelist | wc -l`&lt;BR /&gt;while (${f_cnt} &amp;lt;= ${f_max})&lt;BR /&gt;set src_file = `sed -n "${f_cnt}p" /tmp/filelist`&lt;BR /&gt;if (${#src_file} == 0) exit&lt;BR /&gt;set new_file = "${src_file}.new"&lt;BR /&gt;echo "names read to vars from file"&lt;BR /&gt;echo "${src_file}"&lt;BR /&gt;echo "${new_file}"&lt;BR /&gt;echo "mv command fails"&lt;BR /&gt;mv "${src_file}" "{new_file}"&lt;BR /&gt;@ f_cnt++&lt;BR /&gt;end&lt;BR /&gt;echo "names in filelist"&lt;BR /&gt;cat /tmp/filelist&lt;BR /&gt;------------------------&lt;BR /&gt;&lt;BR /&gt;HELP !!!&lt;BR /&gt;&lt;BR /&gt;If someone could please show me how to read one line at a time from a file and assign it to a var in c shell and have the var maintain the multipule spaces so that the var can then be used to "mv" "del" or whatever on the file from a script.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Rick</description>
      <pubDate>Fri, 19 Dec 2003 11:35:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-c-shell-variables-assigment-from-file/m-p/3149704#M717963</guid>
      <dc:creator>Rick Jones_2</dc:creator>
      <dc:date>2003-12-19T11:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help for C shell variables assigment from file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-c-shell-variables-assigment-from-file/m-p/3149705#M717964</link>
      <description>There is missing $ in mv line.&lt;BR /&gt;It should be&lt;BR /&gt; mv "${src_file}" "${new_file}"</description>
      <pubDate>Fri, 19 Dec 2003 14:01:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-c-shell-variables-assigment-from-file/m-p/3149705#M717964</guid>
      <dc:creator>Vitek Pepas</dc:creator>
      <dc:date>2003-12-19T14:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help for C shell variables assigment from file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-c-shell-variables-assigment-from-file/m-p/3149706#M717965</link>
      <description>This question has already been solved.  See:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=319408" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=319408&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Fri, 19 Dec 2003 14:11:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-c-shell-variables-assigment-from-file/m-p/3149706#M717965</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2003-12-19T14:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help for C shell variables assigment from file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-c-shell-variables-assigment-from-file/m-p/3149707#M717966</link>
      <description>Thanks Everyone for your responses&lt;BR /&gt;&lt;BR /&gt;Rod gave me the answer by using:&lt;BR /&gt;&lt;BR /&gt;setenv src_file "`sed -n "${f_cnt}p" /tmp/filelist`"&lt;BR /&gt;&lt;BR /&gt;instead of what I was using and now the&lt;BR /&gt;&lt;BR /&gt;var keeps the multipule spaces between words.&lt;BR /&gt;&lt;BR /&gt;Thank again Rod&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Dec 2003 14:30:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-c-shell-variables-assigment-from-file/m-p/3149707#M717966</guid>
      <dc:creator>Rick Jones_2</dc:creator>
      <dc:date>2003-12-19T14:30:24Z</dc:date>
    </item>
  </channel>
</rss>

