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

x
?
Solved

detecting if variables start and end with "/"

Posted on 2003-03-14
1
Medium Priority
?
266 Views
Last Modified: 2010-04-21
If I'm reading in a text file:

while read -r subdir1 subdir2 JUNK ; do

I want to check to see if $subdir1 and $subdir2 start and end with a /
0
Comment
Question by:894359
1 Comment
 
LVL 85

Accepted Solution

by:
ozo earned 1000 total points
ID: 8141847
while read -r subdir1 subdir2 JUNK ; do
  slash=/
  case $subdir1 in
  /*/) ;;
  *) slash= ;;
  esac
  case $subdir2 in
  /*/) ;;
  *) slash= ;;
  esac
  if [ "$slash" = "/" ] ; then
     echo $subdir1 and $subdir2 start and end with a /
  fi
done
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
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 find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses

581 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