[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Command substitution with null bytes generates warning
From: |
Greg Wooledge |
Subject: |
Re: Command substitution with null bytes generates warning |
Date: |
Tue, 20 Sep 2016 15:53:02 -0400 |
User-agent: |
Mutt/1.4.2.3i |
On Tue, Sep 20, 2016 at 12:17:37PM -0700, L. A. Walsh wrote:
> /sys/class/net/br0> /tmp/showvals
> addr_assign_type: 1
> addr_len: 6
> address: 00:15:17:bf:be:b2
> /tmp/showvals: line 63: printf: `invalid format character
> brforward: '`f#??
> 7ridge/ageing_time: 30000
> bridge/bridge_id: 8000.001517bfbeb2
So you are just "catting" each file in the current working directory?
Or maybe you just want the first "line" of each file?
Why not simply do:
wooledg@wooledg:/sys/class/net/eth0$ for f in *; do [[ -f $f ]] || continue;
read -r line < "$f" 2>/dev/null; [[ $line ]] && printf '%-25.25s %s\n' "$f:"
"$line"; done
addr_assign_type: 0
address: 6c:3b:e5:2b:f7:19
addr_len: 6
broadcast: ff:ff:ff:ff:ff:ff
carrier: 1
carrier_changes: 2
...
Your example script didn't even *have* a command substitution with a
NUL-byte-containing file in it, as far as I could tell. Of course,
the script was 20 times as large & complex as it needed to be, so I
might have missed some crazy dynamically-constructed thing.
(If you also want it to show the contents of subdirectories, then it
becomes slightly larger. I won't bother writing that one out.)
- Re: Command substitution with null bytes generates warning, (continued)
- Re: Command substitution with null bytes generates warning, Linda Walsh, 2016/09/19
- Re: Command substitution with null bytes generates warning, Greg Wooledge, 2016/09/19
- Re: Command substitution with null bytes generates warning, Linda Walsh, 2016/09/19
- Re: Command substitution with null bytes generates warning, Chet Ramey, 2016/09/19
- Re: Command substitution with null bytes generates warning, L. A. Walsh, 2016/09/19
- Re: Command substitution with null bytes generates warning, Greg Wooledge, 2016/09/19
- Re: Command substitution with null bytes generates warning, Chet Ramey, 2016/09/20
- Re: Command substitution with null bytes generates warning, L. A. Walsh, 2016/09/20
- Re: Command substitution with null bytes generates warning, Greg Wooledge, 2016/09/20
- Re: Command substitution with null bytes generates warning, L. A. Walsh, 2016/09/20
- Re: Command substitution with null bytes generates warning,
Greg Wooledge <=
- Re: Command substitution with null bytes generates warning, L. A. Walsh, 2016/09/20
- Re: Command substitution with null bytes generates warning, L. A. Walsh, 2016/09/20