Solved
Used cut -c 4-
in code and added new variable CURFILE1 which is used to print file "$CURFILE1" {
CURFILE="$(basename "$file")"
CURFILE1=$(echo $CURFILE | cut -c 4-)**
Code part before
cp -a $AUTOFILE $AUTOFILE.old > $AUTOFILE.new
for file in /../pictures/*; do
CURFILE="$(basename "$file")"
cat <<EOF >> $AUTOFILE.new
file "$CURFILE" {
Code part after changes
cp -a $AUTOFILE $AUTOFILE.old > $AUTOFILE.new
for file in /../pictures/*; do
CURFILE="$(basename "$file")"
CURFILE1=$(echo $CURFILE | cut -c 4-)**
cat <<EOF >> $AUTOFILE.new
file "$CURFILE1" {
Hello, can someone help me with bash script? I am working to create auto fill file with information about existing files in directory with some params and more code on it...
Problem is that all files are using prefix ex.: f1.file, so I need to remove f1. and leave only file. Information about found files is stored as information "Text" in one single file.
I need to use some function in bash when files are generating and auto remove prefix in this line file "$CURFILE" {
. CURFILE is the name as example: f1.file and I need to remove that f1.
Just to be more concrete:
- Bash generates text file from all files in directory with custom parameters from code.
- Problem is that text is generated with prefix f1,f2,f3.... because file names is f1.picture f2.test etc..
- I need to show in data file only string without f1,f2,f3... etc..
- Can someone help me to modify this line with some function? (Seed etc I know there is, but I don't know how to addapt it to existing line. Thank you!