Link to home
Start Free TrialLog in
Avatar of Jason_Sutiono
Jason_Sutiono

asked on

How to get just the file name from a file path

Hi guys,

I need a little bit of help here with a shell script that I have attached.

At the moment, it is returning $inputfile1 and $inputfile2 as:
/imports/poupload/input/Invoiced123.csv
/imports/input/upload/Shipped123.csv

Is there a way to just get the file names without the path?(i.e Invoiced123.csv and Shipped123.csv)

I require just the filenames for the parameters of my perl script.

Thanks in advance.

Regards,

Jason

#!/bin/bash

BASEDIR="/imports/upload";

umask 0002

for file in `find "$BASEDIR/input/" -name "Invoiced*" -printf "%f\n"` ; do

	
	inputfile1=$BASEDIR/input/Invoiced*
	inputfile2=$BASEDIR/input/Shipped*

	/cus/imports/test.pl $inputfile1 $inputfile2
	
done

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jason_Sutiono
Jason_Sutiono

ASKER

Thanks ozo thats all I need :D
Or

/cus/imports/test.pl ${inputfile1##*/} ${inputfile2##*/}

wmp