Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Checking for "*" as input

Posted on 2003-03-14
4
Medium Priority
?
262 Views
Last Modified: 2010-04-21
If I am reading in a text file:

while read -r subdir_to_move subdir_to_make JUNK ; do

how do I check to make sure the first character of each variable is not *  ?
0
Comment
Question by:894359
4 Comments
 
LVL 6

Expert Comment

by:bira
ID: 8140755
if [ `echo $subdir_to_move|cut -c1-1` = "*" ] ; then
     echo "the first character of $subdir_to_move is an *"
   else
   echo "the first one is not an *"
fi

  and the same to the other variables
0
 

Author Comment

by:894359
ID: 8140842
I get a weird error when testing your code! I get a:

./mk.sh[67]: findReplaceStatic.pl: unknown test operator

when ever the first character is an * and it still tests false as if the first character is not a *


Also note that for some reason it lists another script in the directory in the error? The script name I'm testing is mk.sh!
0
 
LVL 85

Accepted Solution

by:
ozo earned 500 total points
ID: 8140905
if [ "`echo $subdir_to_move|cut -c1-1`" = "*" ] ; then
    echo "the first character of $subdir_to_move is an *"
  else
  echo "the first one is not an *"
fi
0
 
LVL 48

Expert Comment

by:Tintin
ID: 8141644
No need for cut -c1-1

cut -c1

is fine.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question