[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Spaces in args, escapes, and command substitution
From: |
Bob Proulx |
Subject: |
Re: Spaces in args, escapes, and command substitution |
Date: |
Sun, 29 Oct 2006 03:21:18 -0700 |
User-agent: |
Mutt/1.5.9i |
bash@zacglen.com wrote:
> >Like it or not, POSIX standardized the original bourne shell `` behavior,
> >as well as the ksh $() behavior, and the two behaviors are different. Get
> >used to it.
>
> Well, thank you for telling me to "get used to it". But I do
> not generally obey unreasonable commands.
I doubt the statement was meant as harshly as it sounded.
However some things just are the way that they are and sometimes the
best that you can do is to accept it and move on.
> Now, please tell me how I can edit a bunch of grep'ed files with
> spaces in their names, as in "vi `grep -l xxx *.txt`"
> If I can use IFS then please give an example.
It is unfortunate that your choice of editor does not accept zero
terminated strings as filenames because then this would be easy using
grep's --null option. The problem therefore as I see it is a
deficiency in the editor capabilities.
This is probably not a an optimal solution because this is late night
time for me but this works:
eval vi $(grep -l PATTERN * | sed 's/ /\\ /')
I would suggest xargs but the input is not attached to the terminal in
that case. I think xargs has recently been enhanced to allow this but
it is not in most versions. But batch editing works well.
grep --null -l PATTERN * | xargs -r0 sed --in-place 's/foo/bar/'
Although having spaces in filenames may be common in some cultures it
is definitely not in the Unix culture. Being able to work with file
names with spaces is definitely an afterthought. It is best to avoid
them.
rename 's/ /_/g' *
Bob
- Spaces in args, escapes, and command substitution, bash, 2006/10/24
- Re: Spaces in args, escapes, and command substitution, Andreas Schwab, 2006/10/24
- Re: Spaces in args, escapes, and command substitution, bash, 2006/10/24
- Re: Spaces in args, escapes, and command substitution, bash, 2006/10/28
- Re: Spaces in args, escapes, and command substitution, Eric Blake, 2006/10/29
- Re: Spaces in args, escapes, and command substitution, bash, 2006/10/29
- Re: Spaces in args, escapes, and command substitution, Eric Blake, 2006/10/29
- Re: Spaces in args, escapes, and command substitution, bash, 2006/10/29
- Re: Spaces in args, escapes, and command substitution,
Bob Proulx <=
- Re: Spaces in args, escapes, and command substitution, Bob Proulx, 2006/10/29
- Re: Spaces in args, escapes, and command substitution, bash, 2006/10/29
- Re: Spaces in args, escapes, and command substitution, Eric Blake, 2006/10/29
- Re: Spaces in args, escapes, and command substitution, bash, 2006/10/29
- Re: Spaces in args, escapes, and command substitution, Bob Proulx, 2006/10/29
- Re: Spaces in args, escapes, and command substitution, bash, 2006/10/29
- Re: Spaces in args, escapes, and command substitution, Eric Blake, 2006/10/29
- Re: Spaces in args, escapes, and command substitution, bash, 2006/10/29
- Re: Spaces in args, escapes, and command substitution, Bob Proulx, 2006/10/29
- Re: Spaces in args, escapes, and command substitution, Chet Ramey, 2006/10/29