[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: question about ls



On Fri, Sep 28, 2018 at 09:06:59AM +0200, Ionel Mugurel Ciobîcă wrote:
> On 28-09-2018, at 17h 52'07", Richard Hector wrote about "Re: question about ls"
> > Eww. Tab completion also gets screwed up by this:
> > 
> > richard@zircon:~/test$ rm <tab>
> > file  is    one   this

You're probably using "bash-completion", which is a separate project
from bash, and is known to have many flaws.

> I am not a bash user, but if I try what you suggest, Richard, I see
> the file as "this^Jis^Jone^Jfile" with tab completion (on one line).

And in regular bash (without bash-completion), I see this:

wooledg:/tmp/x$ rm 'this
is
one
file' _

where _ is the cursor.

> P.S. What doesn't mean the $'foo\nbar' construction? In tcsh it says
> "Illegal variable name." and in history it is recalled as $\'foa\nbar'
> instead. I see that ksh also behave as bash with this $'foo\nbar'
> entity.

In bash, $'...' is a special form of quoting which acts like
single-quoting except that certain backslash+letter sequences are expanded
in a way that's similar to C's strings.  For example, \n expands to a
newline character, and \t to a tab.  See the man page for full details.

wooledg:~$ printf %s $' \t\n' | od -tx1 -An
 20 09 0a

It's the cleanest way to specify special characters in an argument string
or a variable assignment.


Reply to: