[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 382
  • Last Modified:

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

0
Jason_Sutiono
Asked:
Jason_Sutiono
1 Solution
 
ozoCommented:
inputfile1=`basename $BASEDIR/input/Invoiced*`
0
 
Jason_SutionoAuthor Commented:
Thanks ozo thats all I need :D
0
 
woolmilkporcCommented:
Or

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

wmp
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now