I have the following bash script
counter=0
for file in /home/ec2-user/Workspace/events_parts/*
do
counter=$[counter + 1]
event=$(cat $file | jq '.Event')
echo $event
if [ "$event" = "Page Exceeded" ] || [ "$event" = "Reporting Time" ]; then
echo "Coming Here"
jq ".url = \"$(jq '.Message' $file | sed 's/.*proxy=\([^&]*\).*/\1/')\"" $file > events_parts/out_$file
else
jq ".url = null" $file > events_parts/out_$file
fi
done
It does processing of a set of JSON files.I want to redirect it to a filename which has out_$input_file_name. But the variable file prints out the whole path not just the file name (for e.g. /home/ec2-user/Workspace/events_parts/input.json) How do I get just the "input file name" from this?