You are not logged in.

#1 2021-06-06 16:55:14

AMTitan
Member
Registered: 2021-04-15
Posts: 33

[Solved] Have find show backslashes

So if I do a find I get something like `./foo bar` but I want to get `./foo\ bar` and I know I can just look for each space but there are some other characters that have the same thing like `./[foo] bar` should be `./\[foo\]\ bar`.

Last edited by AMTitan (2021-06-06 17:49:32)

Offline

#2 2021-06-06 17:08:56

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,694

Re: [Solved] Have find show backslashes

This sounds like an XY problem.  What are you trying to do?   It sounds like you may be trying to parse the output of find rather than use the {} notation where you can substitute the file name actually found in things like exec clauses.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#3 2021-06-06 17:15:11

AMTitan
Member
Registered: 2021-04-15
Posts: 33

Re: [Solved] Have find show backslashes

ewaller wrote:

This sounds like an XY problem.  What are you trying to do?   It sounds like you may be trying to parse the output of find rather than use the {} notation where you can substitute the file name actually found in things like exec clauses.

I am trying to take the output and make a slide show from all the pictures from a lot of different folders and want to do a find from the root directory, but some of the names have spaces and different things that need the backslash.

Offline

#4 2021-06-06 17:49:12

AMTitan
Member
Registered: 2021-04-15
Posts: 33

Re: [Solved] Have find show backslashes

I found it
```
find -print0 | xargs -0 bash -c 'printf "%q\n" "$@"'
```

Offline

Board footer

Powered by FluxBB