Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Linux by (18.4k points)

I was trying to rename the files to another extension:

# mv  *.sqlite3_done *.sqlite3

I am getting an error:

mv: target '*.sqlite3' is not a directory

Why?

1 Answer

0 votes
by (36.8k points)
edited by

The wildcard expansion results in many names being passed to your command. Shell imagines you are trying to move your multiple files to *.sqlite3 directory.

You need to use a loop:

for nam in *sqlite3_done

do

    newname=${nam%_done}

    mv $nam $newname

done

The %_done says to remove the last occurrence of _done from the string.

If you still have spaces in the filenames then you need to quote the filenames.

Come and join Linux training to gain great knowledge. 

Related questions

0 votes
1 answer
0 votes
1 answer
asked Dec 1, 2020 in Linux by blackindya (18.4k points)
0 votes
1 answer
asked Dec 12, 2020 in Linux by blackindya (18.4k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...