Tiny Core Linux
Tiny Core Base => TCB Q&A Forum => Topic started by: Santos on September 06, 2021, 07:53:34 PM
-
Hello
I have a folder as follows:
prueba/
uno/
dos/
tres/
What I want to do is create on each one of the folders a TXT file with the name of its parent folder, like so:
prueba/
uno/uno.txt
dos/dos.txt
tres/tres.txt
For it I'm trying to use find but when I execute the following, nothing happens:
-
Hi Santos
Try the command in the attached file.
-
Hi Rich
Thank you.
I was about to post the remaining of the post but got a message about the server being down.
In 'for loops' I got errors when folder's names are not in ASCII (or with a space). But find will take care of special characters without issues because I can always use inodes for file processing (delete, rename, move, copy, etc).
But I will go ahead a try with the code you share with me.
Also, I'm curious about why the code I attached is not showing up any output.
-
Hi Santos
For starters, tail is the wrong command to strip the leading ./ characters.
Try something like this:
busybox find . -type d -maxdepth 1 | cut -c 3-
-
Thank you.
What I am trying to remove is the current working directory (the dot) showing in find's ouput:
Without the dot and code tags because I'm getting a server error.
(dot)
./uno
./dos
./tres
That's why I wanted to use tail , but cut will be very handy.
-
I found the answer, something not present in the --help output.
busybox find . -not -path .
Same result if the following is used:
busybox find . -mindepth 1
That will do the trick, now I'm just left with my question about tail not processing stdout of find.
-
What happened here is that tail is processing one line at time (due to the implicit loop in find), exactly what I'm telling it to do. Is a formatting error.