strip hostname from dirname?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting strip hostname from dirname?
# 1  
Old 06-17-2008
strip hostname from dirname?

I need to get the full path of a file minus the hostname... anyone have an easy way to do this?

What I have is:
//ourhostname/ourfullpath/filename

What I need is:
/ourfullpath/filename


hostname evaluates to 'ourhostname'

dirname evaluates to '//ourhostname/ourfullpath'

basename evaluates to 'filename'


Thanks in advance.
# 2  
Old 06-17-2008
Use sed:
Code:
sed 's%^//[^/]*%%'

# 3  
Old 06-17-2008
thank you!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Hostname -f hostname: Unknown host

deleted (0 Replies)
Discussion started by: hce
0 Replies

2. Shell Programming and Scripting

Using dirname on a file before uniq

Hello, I have a list of files generated like this: find dir -type f > file_list I want to get a list of just the unique directories. I can't create a temporary file. So the idea is to do a working equivalent to this: cat file_list | dirname | uniq But of course that doesn't... (4 Replies)
Discussion started by: brsett
4 Replies

3. Shell Programming and Scripting

help with dirname

We are using #!/bin/sh From a command line this command returns the correct list of files (without going into any subdirectories) find /vol.prod/saptrans/common/test/pa/* -prune -type f -print We have a script which takes the same path as $1 (without the * ) ... (2 Replies)
Discussion started by: 15a0
2 Replies

4. UNIX for Dummies Questions & Answers

$dirname ??????

Hi, okay, the following command was given to me in a script, but it's not working and there's little to no help on dirname. What is wrong with the following line? I'm just trying to save the current directory to use later in subsequent scripts. MYAPPDIR=$(dirname $(dirname $0)) Thanks. (2 Replies)
Discussion started by: rebazon
2 Replies

5. Emergency UNIX and Linux Support

HP UX - ILO Console hostname different than Machine Hostname...

Hi All, So we added a new HP-UX 11.31 machine. Copied OS via Ignite-UX (DVD)over from this machine called machine_a. It was supposed to be named machine_c. And it is when you log in...however when I'm in the ILO console before logging in, it says: It should say: What gives? And how do... (4 Replies)
Discussion started by: zixzix01
4 Replies

6. Programming

basename and dirname changes the value of argument???

Hi I faced with some interesting behavior of basename and dirname functions from libgen.h: they changes the value of argument! Here is the declaration: char *basename(char *); char *dirname(char *);It makes some tiresome to use them... I am new to C and maybe I do something wrong, but to... (4 Replies)
Discussion started by: Sapfeer
4 Replies

7. Shell Programming and Scripting

dirname, save cut portion to variable, clean up

Hi guys, last cry for help for today. I appreciate the help so far. ok so I have a program that dumps a path into my script as a variable ($1) This path is an example /home/xbmc/sab_downloads/video/tv/grey's anatomy/season 3 So in order to search thetvdb.com for a show, I need to extract... (6 Replies)
Discussion started by: tret
6 Replies

8. Shell Programming and Scripting

Setting basename and dirname variable to simply script.

Hello all, Can somebody explain to me how set up a basename and dirname variable to simplify this script. I currently have a 'infile' with the contents of FTTPDataPVC_ & BaaisDSLFeed. I need to add a basename and or dirname variable so that any additions can be made through the infile and not... (1 Reply)
Discussion started by: liketheshell
1 Replies

9. UNIX for Dummies Questions & Answers

Solaris - unknown hostname - how can I change hostname?

Hello, I am new to Solaris. I am using stand alone Solaris 10.0 for test/study purpose and connecting to internet via an ADSL modem which has DHCP server. My Solaris is working on VMWare within winXP. My WinXP and Solaris connects to internet by the same ADSL modem via its DHCP at the same... (1 Reply)
Discussion started by: XNOR
1 Replies
Login or Register to Ask a Question