Getting a file name from input file

Hi

suppose I run my script using an argument (abc.xyz)
i want to strip the extension off nad just use the file name for further manipulations.

any ideas ?

~thanks

echo "abc.xyz" | awk -F. '{print $1}'
abc
echo ${1%.*}

where $1 is the first argument passed to the script. If you are storing the argument in a variable, you can use

echo ${FILENAME%.*}

where FILENAME is the variable which stores the argument passed.

how about this ??

fullname="$1"
echo $fullname
name= "$fullname" | cut -f1 -d"."
echo $name

echo fullname works
bt cut command isnt working

what do i do ?

---------- Post updated at 03:23 PM ---------- Previous update was at 03:19 PM ----------

and what about this ??

malo901_cp-link_0807_020.csv

what If I want only cp-link out of it ??

Replace name= "$fullname" | cut -f1 -d"." with

name=$(echo "$fullname" | cut -f1 -d".")

---------- Post updated at 03:27 PM ---------- Previous update was at 03:24 PM ----------

echo "malo901_cp-link_0807_020.csv" | cut -d"_" -f 2

Thanks all :slight_smile:

If you always know the extension and if it static..says extension is always xyz then you can use 'basename'

>basename abc.xyz .xyz
abc