The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 02-02-2008
3dtiger 3dtiger is offline
Registered User
 

Join Date: Feb 2008
Posts: 3
Open file with correct application

Can someone please help me with my bourne shell script. I am a struggling newbie. I need create a script that will read an argument from a command line, access a config file with application file types, and open the file with the correct application. The file needs to be able to handle file extensions like .c or .h and exceptions. My config looks like:

#This is a sample .dorc

Application/PostScript ps /usr/bin/ggv

and my current shell script:

#!/usr/bin/bash

filename=$(basename ${1})
echo $1
file_ext=${filename##*.}
echo $file_ext
line=$(grep $file_ext sample.dorc | cut -f3 $i)
$line $1

Thanks in advance for any help.
Reply With Quote
Remove advertisements
!!
Forum Sponsor