I am able to do this in shell command line.
filename="/home/vikrant_singh_rana/testing/110001_ABC Traffic_04May2020_header_only.csv" output_filename=$(basename "$filename") cat "/home/vikrant_singh_rana/testing/110001_ABC Traffic_04May2020_header_only.csv" > /home/vikrant_singh_rana/enrichment_files/"$output_filename"
It was able to read given file from
'/home/vikrant_singh_rana/testing' and has written file with same name to other dir
When I am doing same thing in shell script. Its not working
#!/bin/bash # Go to where the files are located filedir=/home/vikrant_singh_rana/testing/* first='yes' #reading file from directory for filename in $filedir; do #echo $filename output_filename=$(basename "$filename") #echo $output_filename #done done > /home/vikrant_singh_rana/enrichment_files/"$output_filename"
while running this I am getting this error
/home/vikrant_singh_rana/enrichment_files/: Is a directory