LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 07-11-2020, 03:07 AM   #1
blueray
Member
 
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.

Code:
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

Code:
**/|*[[:upper:]]*(od)
is searching for uppercase letter in any file or directory name recursively. What is the significance of | after /.

For the second part

Code:
${(M)f##*/}${(L)${${f##*/}//(#b)([[:upper:]])/-$match[1]}#-}
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
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 1,140

Rep: Reputation: Disabled
Quote:
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
blueray
Member
 
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.
 
  


Reply

Tags
zsh


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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

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