detecting if variables start and end with "/"

Posted on 2003-03-14
Medium Priority
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 /
Question by:894359
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
LVL 84

Accepted Solution

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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

771 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