[mdlug] How to find file name length?
Paul
set at pobox.com
Thu Sep 27 01:16:34 EDT 2007
Raymond McLaughlin <driveray at ameritech.net>, on Wed Sep 26, 2007 [06:51:55 PM] said:
>
> Also did any one notice that the "echo "$(basename "{}" | wc -c" part
> doesn't work as intended? Observe:
>
> echo filename.txt | wc -c
> 13
>
> wc counts the trailing new line as a character, you need to use "echo -n"
>
> echo -n filename.txt | wc -c
> 12
>
>
> Ray
Hi;
Yeah, I noticed;) its called slop. You cant just shove a
-n into my example without having to do something extra, since Im
just using one echo, the -n wouldn't truncate the right newline,
and you would just get a big blob of output. (the result length
is calculated before echo gets involved.)
Paul
set at pobox.com
More information about the mdlug
mailing list