Sponsored Content
Top Forums Shell Programming and Scripting how to get fully qualified path name Post 302341106 by dr.house on Wednesday 5th of August 2009 05:28:07 AM
Old 08-05-2009
Code:
#! /bin/bash
# filePath.bash
# (experimental)

INPUT=$1

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

echo $FILE
echo $PATH

exit 0

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

 

8 More Discussions You Might Find Interesting

1. 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

2. 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 hostname.xxx.xxxxxx.com... (3 Replies)
Discussion started by: sdspawankumar
3 Replies

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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
PPPOE-DISCOVERY(8)					      System Manager's Manual						PPPOE-DISCOVERY(8)

NAME
pppoe-discovery - perform PPPoE discovery SYNOPSIS
pppoe-discovery [ options ] pppoe-discovery { -V | -h } DESCRIPTION
pppoe-discovery performs the same discovery process as pppoe, but does not initiate a session. It sends a PADI packet and then prints the names of access concentrators in each PADO packet it receives. OPTIONS
-I interface The -I option specifies the Ethernet interface to use. Under Linux, it is typically eth0 or eth1. The interface should be "up" before you start pppoe-discovery, but should not be configured to have an IP address. The default interface is eth0. -D file_name The -D option causes every packet to be dumped to the specified file_name. This is intended for debugging only. -U Causes pppoe-discovery to use the Host-Uniq tag in its discovery packets. This lets you run multiple instances of pppoe-discovery and/or pppoe without having their discovery packets interfere with one another. You must supply this option to all instances that you intend to run simultaneously. -S service_name Specifies the desired service name. pppoe-discovery will only accept access concentrators which can provide the specified service. In most cases, you should not specify this option. Use it only if you know that there are multiple access concentrators or know that you need a specific service name. -C ac_name Specifies the desired access concentrator name. pppoe-discovery will only accept the specified access concentrator. In most cases, you should not specify this option. Use it only if you know that there are multiple access concentrators. If both the -S and -C options are specified, they must both match. -A This option is accepted for compatibility with pppoe, but has no effect. -V | -h Either of these options causes pppoe-discovery to print its version number and usage information, then exit. AUTHORS
pppoe-discovery was written by Marco d'Itri <md@linux.it>, based on pppoe by David F. Skoll <dfs@roaringpenguin.com>. SEE ALSO
pppoe(8), pppoe-sniff(8) 22 January 2006 PPPOE-DISCOVERY(8)
All times are GMT -4. The time now is 08:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy