Groups | Search | Server Info | Login | Register


Groups > alt.comp.lang.shell.unix.bourne-bash > #291

Re: Bash passing a filename with a space into xargs?

From Lewis <g.kreme@kreme.dont-email.me>
Newsgroups alt.comp.lang.shell.unix.bourne-bash
Subject Re: Bash passing a filename with a space into xargs?
Date 2022-04-02 18:56 +0000
Organization Miskatonic U
Message-ID <slrnt4h739.2m5.g.kreme@zephyrus.local> (permalink)
References <9a9f0a6f-9389-4f38-b1e4-69e7ac2b4070n@googlegroups.com> <t27m35$t44$1@dont-email.me>

Show all headers | View raw


In message <t27m35$t44$1@dont-email.me> Michael F. Stemper <michael.stemper@gmail.com> wrote:
> On 01/04/2022 11.21, Chris Roberts wrote:
>> How can I get this to recognize a filename with a space?
>> I am manipulating files in my script, but at the portion where I want to do a diff. I cannot get it to work.
>> Would someone out there know of a workaround?  (Besides saying "don't have filenames with spaces in them).  :-)
>> 
>> This is in bash:
>> uno="try this.txt"
>> dos=blah.pdf
>> echo "$uno" "$dos" | xargs -l bash -c 'echo uno:$0 dos:$1' | xargs  	
>> #OUT: uno:try dos:this
>> 
>> echo "$uno" "$dos" | xargs -l bash -c 'echo uno:$0 dos:$1'
>> #OUT: uno:try dos:this
>> 
>> echo uno:"$uno", dos:"$dos"  #this works, but doesn't help in my script.
>> #OUT: uno:try this.txt, dos:blah.pdf

> I can't quite tell what you're trying to do, but single quotes around
> the definition of uno seems to help:


>============================
> #!/bin/bash

> uno='try this.txt'
> dos=blah.pdf

> ls "$uno" "$dos"
>============================


Also, IFS=$'\n' is an option.


-- 
It was all very well going about pure logic and how the universe was
	ruled by logic and the harmony of numbers, but the plain fact was
	that the disc was manifestly traversing space on the back of a
	giant turtle and the gods had a habit of going round to atheists'
	houses and smashing their windows.

Back to alt.comp.lang.shell.unix.bourne-bash | Previous | NextPrevious in thread | Find similar


Thread

Bash passing a filename with a space into xargs? Chris Roberts <thecjguy1@gmail.com> - 2022-04-01 09:21 -0700
  Re: Bash passing a filename with a space into xargs? "Michael F. Stemper" <michael.stemper@gmail.com> - 2022-04-01 15:07 -0500
    Re: Bash passing a filename with a space into xargs? Lewis <g.kreme@kreme.dont-email.me> - 2022-04-02 18:56 +0000

csiph-web