LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   msdos dir cmd vs linux ls (https://www.linuxquestions.org/questions/linux-newbie-8/msdos-dir-cmd-vs-linux-ls-4175690805/)

Gebby_3 02-19-2021 09:07 AM

msdos dir cmd vs linux ls
 
Windows 10 cmd prompt syntax:

dir /b /s d:\!Mp3_A-Z\*.mp3 > d:\!mp3list\filename.lst

What would be the unix equivalent using possibly ls?

I am running a mks unix shell and/or Cgywin

Hoping the unix syntax would run faster.

Finding over 100,000 + lines

pan64 02-19-2021 09:14 AM

no, it won't be faster. dir should work better on windows.
The syntax would be something like:
ls <cygwin root dir>/cygdrive_d/\!Mp3_A-Z/*.mp3 > target_file

Gebby_3 02-19-2021 09:53 AM

ls <cygwin root dir>/cygdrive_d/\!Mp3_A-Z/*.mp3 > target_file

Only returns the 8.3 filename format and my dir's also have a "^" in the dirname.
I can easily change the carrot.

The find cmd reacts the same (8.3)

I'm also getting file "*.mp3" not found (There are many subfolders in !Mp3_A-Z)
and are not any in the parent folder !Mp3_A-Z)

Searching my cobwebs from Xenix in the '80's before the company jumped to "Bill Gates"
That was I felt a step backwards but I was only following orders.

pan64 02-19-2021 10:00 AM

so ls is not really suitable here. That is not a step backward, but mixing windows and linux which is not a good idea (in general).

boughtonp 02-19-2021 10:14 AM

Quote:

Originally Posted by Gebby_3 (Post 6222114)
Windows 10 cmd prompt syntax:

dir /b /s d:\!Mp3_A-Z\*.mp3 > d:\!mp3list\filename.lst

What would be the unix equivalent using possibly ls?

As per "dir /?":
Quote:

/B Uses bare format (no heading information or summary).
/S Displays files in specified directory and all subdirectories.
So "/B" is a single filename per line, which is achieved with "-1" for ls.
And "/S" is a recursive listing which is achieved with "-R" for ls.

If you do "ls /path/*.ext" you'll get the path prefixed to filenames.
To avoid that you should do "cd /path/; ls*.txt; cd -" or "pushd /path/; ls*.txt; popd"


As I mentioned in your other thread: ditch MKS Toolkit and just use MinGW (either via MSys2 or Git) then you can use a standard Bash shell & other GNU tools, which makes it easier for anything you write to be cross-platform.

I can confirm neither Git Bash nor MSys Bash will give you 8.3 filenames. (They also allow you to simply write "/d/directory/" and/or drag files into the terminal to have the full path populated).



All times are GMT -5. The time now is 03:01 PM.