0

I have many folders with the following pattern:

$ ls
a-master 123-master abc123-master

I want them to be:

$ ls
a 123 abc123

During my research, I found this answer. But when I ran mv "$f" "${f/-master/}", I got mv: rename to : No such file or directory error and I'm not sure why.

I found many answers recommending rename package but I don't prefer it. I think it's possible to be done just by using mv command but I'm not entirely sure how.

Does is possible? If possible, what is the correct command for this case?

I'm looking for one liner command, a short and sweet one.

Zulhilmi Zainudin
  • 9,017
  • 12
  • 62
  • 98

1 Answers1

0

I am fetching details from the shared link-

for f in opencv_*; do mv "$f" "${f/.so/}"; done

The mv command is working on a loop where f is defined as a temporary variable, whereas the query posted does not have a variable. (f == "")

Example, mkdir abc123-master export F=abc123-master mv $F ${F/-master/} ls -rlt abc123

Jatish
  • 352
  • 1
  • 2
  • 10