how to get fully qualified path name

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to get fully qualified path name
# 1  
Old 08-04-2009
how to get fully qualified path name

actually i want to get fully qualified path name of the file when the file name is entered as command line argument while running a shell script
ex. if i run the shell as
$./ ./nsdnet_file.csv

the it should display me the full path of the file like


Last edited by Yogesh Sawant; 08-04-2009 at 07:36 AM.. Reason: added code tags
# 2  
Old 08-04-2009
Try something like:

echo $full

# 3  
Old 08-04-2009
actually this will work only if the nsdnet_file.csv is in the same directory as the shell script.

what if the nsdnet_file is one dir ahead of the shelll script

like if we execute like

$./ ../nsdnet_file.csv
then it should also give the correct path i.e /dialp/Release
# 4  
Old 08-05-2009
#! /bin/bash
# filePath.bash
# (experimental)


FILE=$( basename $INPUT )
PATH=$( echo $INPUT | sed "s/$FILE//" )
PATH=$( cd $PATH && pwd && cd - > /dev/null 2>&1 )

echo $FILE
echo $PATH

exit 0

[house@discovery] pwd
[house@discovery] sh filePath.bash ../this.file
[house@discovery] sh filePath.bash /root/cron/that.file
[house@discovery] sh filePath.bash ../house/Desktop/no.file

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with script to fully occupied all available cpu

I have long list of file wanna processed by a program: data_1.txt data_2.txt data_3.txt data_4.txt data_5.txt data_6.txt data_7.txt data_8.txt . . data_1_2.txt data_2_2.txt data_3_2.txt data_4_2.txt data_5_2.txt data_6_2.txt . (12 Replies)
Discussion started by: perl_beginner
12 Replies

2. Solaris

Can't change fully qualified host name

I tried changing my /etc/inet/hosts file for my server to: <ip address> <hostname> <fqdn> but when I go to reboot the file changes right back to: <ip address> <hostname> how do I get the <fqdn> to stick on a reboot. Thanks (2 Replies)
Discussion started by: jastanle84
2 Replies

3. Shell Programming and Scripting

FTP file from MF to AIX, fully encrypted

Hi All, I have connected to MainFrame system from Unix AIX Server then using ftp i get the file "NJUSP_XYXYXY_NONONO" to Unix. Now when i tried opening this file using cat/more i am getting the content fully in encrypted format. please help me to read the content of this file from my Unix... (5 Replies)
Discussion started by: Arunprasad
5 Replies

4. UNIX for Advanced & Expert Users

Setup a Fully Featured C++ Develop Environment

Hello, I'm learning C++ and i want to know what i have to do for setup a fully featured C++ develop environment in my Ubuntu Intrepid Ibex, like Gedit, because i hate eMacs and non-graphical editors, they are so much confusing, and some other things that will help me with my development. ... (7 Replies)
Discussion started by: nathanpc
7 Replies

5. IP Networking

Unable to ping freebsd machine using fully qualified domain name

hi all. am unable to ping a freebsd machine using fully qualified domain name from a windows machine. i have already set the fqdn for the machine. plz advise me. thanks. (2 Replies)
Discussion started by: coolatt
2 Replies

6. Shell Programming and Scripting

Very Challenging Problem. Please read fully.

Hi, This is the Third thread i'm putting here for the same problem. :( Actually, i'm trying a script like this.. but its taking a long time.. about 3 days to complete fully.. #!/bin/ksh if then exit 1 fi while read i do while read j do field7=`echo $j|cut -d "|"... (12 Replies)
Discussion started by: RRVARMA
12 Replies

7. Solaris

Hostname not fully qualified..

Hi Friends.. I have a small problem with the hostname of my system.I had installed Solaris 10 X86 on Vmware in my windows 2000 system.After booting of my solaris system,if i give check-hostname command it says ,, hostname is not fully qualified ,,change the hostname to (3 Replies)
Discussion started by: sdspawankumar
3 Replies

8. Programming

find the fully-qualified path for the app my module is running in

Hi- I need the cpp call that will tell me the full path to the app I'm running in. For example, I'm running in a loaded library for either mozilla or firefox, but would like to know the full path to the executable /usr/bin/firefox /usr/bin/mozilla /usr/local/firefox1_5 etc... (For... (4 Replies)
Discussion started by: erwinfletch
4 Replies
Login or Register to Ask a Question