|
Home > Archive > Red Hat Topics > March 2005 > Simple question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Cor van den Berghe 2005-03-07, 7:45 am |
| Can anybody tell me if there is a Linux command that gives the length of the
filename (including full path)
Tia
Cor van den Berghe
| |
|
| Cor van den Berghe wrote:
> Can anybody tell me if there is a Linux command that gives the length of
> the filename (including full path)
>
> Tia
> Cor van den Berghe
Do you mean bash, shell command?
http://linuxreviews.org/beginner/ab...e/en/x4299.html
FN="abcd.swx"
echo ${#FN}
$ echo "$FN" | awk '{print length()}'
$ echo $(expr length $FN)
$ ls | awk '{print $0,length($0)}'
Google search returns other variants too
$ echo `expr "$FN" : '.*'`
$ man dirname
$ man basename
------------------------------------
Good question, but u learn to google.
| |
| Spamless 2005-03-07, 5:45 pm |
| On 2005-03-07, moma <moma@example.net> wrote:
> Cor van den Berghe wrote:
>
> Do you mean bash, shell command?
>
> http://linuxreviews.org/beginner/ab...e/en/x4299.html
>
>
> FN="abcd.swx"
>
> echo ${#FN}
>
> $ echo "$FN" | awk '{print length()}'
You may have to suppress echo supplying an EOL marker (or be off one)
And how about the simpler"
echo -n "text" | wc -m
(Watch the version of echo and the switches.
The tcshell and bash have their own built in
versions different from the external /bin/echo)
(man wc)
|
|
|
|
|