Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-11-2020, 03:07 AM   #1
Registered: Feb 2020
Location: Bangladesh
Distribution: Debian, Ubuntu, Linux Mint
Posts: 91

Rep: Reputation: 0
Not Understanding zmv Command

I got the following command to rename both files and directories recursively from pascel or camel case to kebab case.

zmv -Q '**/|*[[:upper:]]*(od)' '${(M)f##*/}${(L)${${f##*/}//(#b)([[:upper:]])/-$match[1]}#-}'
This command works beautifully. However, I am not understanding a lot of concepts from this command.

I understand that

is searching for uppercase letter in any file or directory name recursively. What is the significance of | after /.

For the second part

I understand that (M) flag is used to remove the non-matched elements.

${f##*/} is used to get filename without path.

However, as a whole I do not have complete idea on how the command is working.

Can anyone please help.
Old 07-12-2020, 12:30 PM   #2
Senior Member
Registered: Mar 2020
Posts: 1,140

Rep: Reputation: Disabled
Originally Posted by blueray View Post
What is the significance of | after /
| selects alternatives just the same as in extended regular expressions. Without it here the rename action wouldn't apply to the top level files and directories. And (od) ensures they will be acted upon after the files and directories on the lower levels. Think of it as of the -depth option to find.

As for the second part, I guess you already found the answer judging from your other thread.
1 members found this post helpful.
Old 07-13-2020, 01:58 AM   #3
Registered: Feb 2020
Location: Bangladesh
Distribution: Debian, Ubuntu, Linux Mint
Posts: 91

Original Poster
Rep: Reputation: 0
Thank you very much for the feedback.

Yes I found the other answers.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Help with understanding the 'with' keyword and understanding file reading and writing. vysero Programming 3 05-30-2018 02:37 PM
[SOLVED] Choice for t130 dell server embedded sata or not- not understanding the choice presented on Dell website? alpinisteo Linux - Server 4 05-12-2018 06:00 AM
understanding read command as a test frankie_DJ Programming 11 08-08-2005 01:30 PM
help understanding this command vince_2x Linux - General 4 09-21-2004 12:42 AM
burning cdrs using cdrecord (ver2.0) from the command line (understanding) hamster Linux - General 2 05-13-2003 06:38 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:44 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration