王虎
unread,Nov 11, 2009, 10:16:45 PM11/11/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to china-li...@googlegroups.com
hi, all
我要写一个简单的 shell, 碰到一个问题: 传进来的参数是一个文件的完整路径, 要得到这个文件所在的目录, 要怎么办?
# !/bin/bash
# get_dir.sh
echo file full name : $1
DIR=...
...
.....
echo dir name : $DIR
调用这个 shell 脚本 : ./get_dir.sh /home/data/1.txt
期望的输出是:
file full name : /home/data/1.txt
file dir name : /home/data/
请大家帮帮吗.