<?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: Shell programming: Search a blank in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561802#M919461</link>
    <description>And finally if you need to search for a blank in the file name, try this:&lt;BR /&gt;&lt;BR /&gt;if &lt;BR /&gt;  echo $FILE | grep " "&lt;BR /&gt;then&lt;BR /&gt;  ...&lt;BR /&gt;fi</description>
    <pubDate>Mon, 06 Aug 2001 08:26:51 GMT</pubDate>
    <dc:creator>Uffe Gavnholt_1</dc:creator>
    <dc:date>2001-08-06T08:26:51Z</dc:date>
    <item>
      <title>Shell programming: Search a blank</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561798#M919457</link>
      <description>Hi!&lt;BR /&gt;&lt;BR /&gt;I'm creating a shell script, and I want to execute a command only if there is a blank in ${FILE}.&lt;BR /&gt;&lt;BR /&gt;How could I carry it out?&lt;BR /&gt;&lt;BR /&gt;if _?_?_?_ then&lt;BR /&gt;   [command]&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Thank you very much.</description>
      <pubDate>Mon, 06 Aug 2001 07:42:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561798#M919457</guid>
      <dc:creator>Miguel Cuesta</dc:creator>
      <dc:date>2001-08-06T07:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: Shell programming: Search a blank</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561799#M919458</link>
      <description>If, by blank, you mean the file is empty, then:&lt;BR /&gt;&lt;BR /&gt;if ! [ -s $FILE ] ; then&lt;BR /&gt;...&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;but if you mean a single space as the only line, then:&lt;BR /&gt;&lt;BR /&gt;if [ `cat $FILE | wc -w` -eq 0 ] ; then&lt;BR /&gt;...&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;could be one way to do it.&lt;BR /&gt;&lt;BR /&gt;Robin</description>
      <pubDate>Mon, 06 Aug 2001 07:55:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561799#M919458</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2001-08-06T07:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: Shell programming: Search a blank</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561800#M919459</link>
      <description>If you are really looking for a blank (" ") and not a blank file or a blank line in this file you could use:&lt;BR /&gt;&lt;BR /&gt;if [ `grep -c " " $FILE`] ; then &lt;BR /&gt;... &lt;BR /&gt;fi &lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;BR /&gt;&lt;BR /&gt;Regards Stefan</description>
      <pubDate>Mon, 06 Aug 2001 08:15:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561800#M919459</guid>
      <dc:creator>Stefan Schulz</dc:creator>
      <dc:date>2001-08-06T08:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: Shell programming: Search a blank</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561801#M919460</link>
      <description>Hi&lt;BR /&gt;  If you are looking for a blank line in a file&lt;BR /&gt;&lt;BR /&gt;while read each_line;do&lt;BR /&gt;echo $each_line | grep " " &amp;gt; /dev/null&lt;BR /&gt;if [ $? -eq 0 ];then&lt;BR /&gt; echo $each_line&lt;BR /&gt; .&lt;BR /&gt; .&lt;BR /&gt; .&lt;BR /&gt;fi&lt;BR /&gt;done&lt;A.LST&gt;&lt;/A.LST&gt;&lt;BR /&gt;  where a.lst in the input file&lt;BR /&gt;&lt;BR /&gt;..PRB...</description>
      <pubDate>Mon, 06 Aug 2001 08:26:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561801#M919460</guid>
      <dc:creator>Praveen Bezawada</dc:creator>
      <dc:date>2001-08-06T08:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: Shell programming: Search a blank</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561802#M919461</link>
      <description>And finally if you need to search for a blank in the file name, try this:&lt;BR /&gt;&lt;BR /&gt;if &lt;BR /&gt;  echo $FILE | grep " "&lt;BR /&gt;then&lt;BR /&gt;  ...&lt;BR /&gt;fi</description>
      <pubDate>Mon, 06 Aug 2001 08:26:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561802#M919461</guid>
      <dc:creator>Uffe Gavnholt_1</dc:creator>
      <dc:date>2001-08-06T08:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: Shell programming: Search a blank</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561803#M919462</link>
      <description>I meant 'a blank in the __file name__'&lt;BR /&gt;&lt;BR /&gt;Thank you.</description>
      <pubDate>Mon, 06 Aug 2001 09:13:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561803#M919462</guid>
      <dc:creator>Miguel Cuesta</dc:creator>
      <dc:date>2001-08-06T09:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Shell programming: Search a blank</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561804#M919463</link>
      <description>Using Uffe's script, I get this message:&lt;BR /&gt;&lt;BR /&gt;./myscript.sh[43]: test: A ] character is missing.&lt;BR /&gt;grep: can't open ]</description>
      <pubDate>Mon, 06 Aug 2001 09:24:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561804#M919463</guid>
      <dc:creator>Miguel Cuesta</dc:creator>
      <dc:date>2001-08-06T09:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: Shell programming: Search a blank</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561805#M919464</link>
      <description>You can use:&lt;BR /&gt;&lt;BR /&gt;if [ `echo $FILE | wc -w` -gt 1 ]&lt;BR /&gt;then&lt;BR /&gt;   commands&lt;BR /&gt;fi</description>
      <pubDate>Mon, 06 Aug 2001 09:40:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561805#M919464</guid>
      <dc:creator>Dave Kelly_1</dc:creator>
      <dc:date>2001-08-06T09:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: Shell programming: Search a blank</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561806#M919465</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;Try this one.&lt;BR /&gt;&lt;BR /&gt;FILE="File Name" #Let's say var is like this.&lt;BR /&gt;echo $FILE|grep " " &amp;gt;/dev/null&lt;BR /&gt;if [ $? -ne 0 ]&lt;BR /&gt;then&lt;BR /&gt;echo " There is sapce" #U can run ur script here.&lt;BR /&gt;else&lt;BR /&gt;echo "No space"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Hope this may help u.</description>
      <pubDate>Mon, 06 Aug 2001 09:42:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561806#M919465</guid>
      <dc:creator>Joseph Chakkery</dc:creator>
      <dc:date>2001-08-06T09:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: Shell programming: Search a blank</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561807#M919466</link>
      <description>Hello Miguel,&lt;BR /&gt;&lt;BR /&gt;first you will have to *quote* anyway ;-)&lt;BR /&gt;Then, if you are looking for the values of "${FILE}" as&lt;BR /&gt;a variable, test it like this:&lt;BR /&gt;   if [ "${FILE}" = " " ]&lt;BR /&gt;   then echo "Bingo - a space only"&lt;BR /&gt;   fi&lt;BR /&gt;&lt;BR /&gt;Or you can insert some (almost) arbitrary characters&lt;BR /&gt;for readability:&lt;BR /&gt;   if [ "x${FILE}x" = "x x" ]&lt;BR /&gt;   then echo "Bingo - a space only"&lt;BR /&gt;   fi&lt;BR /&gt;&lt;BR /&gt;But if you are checking wether there is file with the name&lt;BR /&gt;in "${FILE}", and this only contains a single space, you&lt;BR /&gt;will have to do something like:&lt;BR /&gt;   if [ "$(wc -c ${FILE})" -eq 1 ]&lt;BR /&gt;   then if [ "$(cat ${FILE})" = " " ]&lt;BR /&gt;      then echo Bingo - the files contains only a space&lt;BR /&gt;      else echo file is only one char in size but not a space&lt;BR /&gt;      fi&lt;BR /&gt;   fi&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;   Wodisch&lt;BR /&gt;&lt;BR /&gt;PS: You could use "perl", where you have direct access&lt;BR /&gt;      to the file's attributes, like size, and where file-&lt;BR /&gt;      handling is pretty simple...</description>
      <pubDate>Mon, 06 Aug 2001 10:42:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561807#M919466</guid>
      <dc:creator>Wodisch</dc:creator>
      <dc:date>2001-08-06T10:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: Shell programming: Search a blank</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561808#M919467</link>
      <description>Hi Miguel,&lt;BR /&gt;&lt;BR /&gt;# The argument for the grep is one blank&lt;BR /&gt;echo $fileName ? grep " " &amp;gt; /dev/null&lt;BR /&gt;if [[ $? = 0 ]]&lt;BR /&gt;then &lt;BR /&gt;echo " File name contains at least one blank"&lt;BR /&gt;else&lt;BR /&gt;echo " File name does not contains at least one blank"&lt;BR /&gt;fi &lt;BR /&gt;&lt;BR /&gt;Magdi</description>
      <pubDate>Mon, 06 Aug 2001 10:50:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561808#M919467</guid>
      <dc:creator>Magdi KAMAL</dc:creator>
      <dc:date>2001-08-06T10:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: Shell programming: Search a blank</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561809#M919468</link>
      <description>in the ksh:&lt;BR /&gt;&lt;BR /&gt;if [[ "$file" = *+( )* ]] then&lt;BR /&gt;&lt;BR /&gt;or for other white space character also&lt;BR /&gt;&lt;BR /&gt;if [[ "$file" = *+([:space:])* ]] then</description>
      <pubDate>Mon, 06 Aug 2001 17:06:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561809#M919468</guid>
      <dc:creator>Curtis Larson_1</dc:creator>
      <dc:date>2001-08-06T17:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: Shell programming: Search a blank</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561810#M919469</link>
      <description>You're always going to stuggle testing for spaces in shell because it's a delimeter.  What about awk?&lt;BR /&gt;&lt;BR /&gt;echo "$file" | awk 'BEGIN {FS=""} / / {print "*" }' &lt;BR /&gt;&lt;BR /&gt;Will print an asterix if $file contains one or more spaces, including leading and trailing spaces.&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;BR /&gt;Phil&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Aug 2001 08:35:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561810#M919469</guid>
      <dc:creator>Phil Squire</dc:creator>
      <dc:date>2001-08-07T08:35:02Z</dc:date>
    </item>
    <item>
      <title>Re: Shell programming: Search a blank</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561811#M919470</link>
      <description>If the variable FILE is to be tested for an embedded blank:&lt;BR /&gt;&lt;BR /&gt;set -A temp $FILE&lt;BR /&gt;[ ${#temp[*]} -gt 0 ] &amp;amp;&amp;amp; echo "$FILE has a blank"&lt;BR /&gt;&lt;BR /&gt;All shell builtin commands - no fork/exec&lt;BR /&gt;&lt;BR /&gt;David&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Aug 2001 12:57:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561811#M919470</guid>
      <dc:creator>David G Ledger</dc:creator>
      <dc:date>2001-08-09T12:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: Shell programming: Search a blank</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561812#M919471</link>
      <description>case "$FILE" in&lt;BR /&gt;  *' '*) ... ;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;Simple, efficient, works in every sh-type shell from original Bourne up.&lt;BR /&gt;</description>
      <pubDate>Sun, 12 Aug 2001 16:16:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561812#M919471</guid>
      <dc:creator>Tapani Tarvainen</dc:creator>
      <dc:date>2001-08-12T16:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: Shell programming: Search a blank</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561813#M919472</link>
      <description>Of course I meant &lt;BR /&gt;&lt;BR /&gt;[ ${#temp[*]} -gt 1 ] &amp;amp;&amp;amp; echo "$FILE has a blank"</description>
      <pubDate>Tue, 14 Aug 2001 11:52:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming-search-a-blank/m-p/2561813#M919472</guid>
      <dc:creator>David G Ledger</dc:creator>
      <dc:date>2001-08-14T11:52:54Z</dc:date>
    </item>
  </channel>
</rss>

