* FSpecs
@ 2002-11-14 8:56 BEN RITCHEY
2002-11-14 21:52 ` FSpecs Paul Kraus
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: BEN RITCHEY @ 2002-11-14 8:56 UTC (permalink / raw)
To: linux-newbie
Originally to: ALL
Would it be possible in a Bash script to munge a Long File Name to the older
DOS 8.3 format?
In my case I need the first 8 characters and the last 4 (.xxx) ... the
resulting string would then be used as an argument for another command. :)
--
Keep the faith,
: Ben http://bellsouthpwp.net/c/m/cmech617 ICQ #32457590
:
+ WildCat! Board 24/7 (337) 232-4155 33.6kBps 8,N,1 Files!
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: FSpecs
2002-11-14 8:56 FSpecs BEN RITCHEY
@ 2002-11-14 21:52 ` Paul Kraus
2002-11-14 21:56 ` FSpecs hackob
2002-11-15 14:43 ` FSpecs ichi
2 siblings, 0 replies; 6+ messages in thread
From: Paul Kraus @ 2002-11-14 21:52 UTC (permalink / raw)
To: 'BEN RITCHEY'; +Cc: linux-newbie
It would be a lot easier to do it with gawk or perl.
-----Original Message-----
From: linux-newbie-owner@vger.kernel.org
[mailto:linux-newbie-owner@vger.kernel.org] On Behalf Of BEN RITCHEY
Sent: Thursday, November 14, 2002 3:57 AM
To: linux-newbie@vger.kernel.org
Subject: FSpecs
Originally to: ALL
Would it be possible in a Bash script to munge a Long File Name to the
older DOS 8.3 format?
In my case I need the first 8 characters and the last 4 (.xxx) ... the
resulting string would then be used as an argument for another command.
:)
--
Keep the faith,
: Ben http://bellsouthpwp.net/c/m/cmech617 ICQ #32457590
:
+ WildCat! Board 24/7 (337) 232-4155 33.6kBps 8,N,1 Files!
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie"
in the body of a message to majordomo@vger.kernel.org More majordomo
info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: FSpecs
2002-11-14 8:56 FSpecs BEN RITCHEY
2002-11-14 21:52 ` FSpecs Paul Kraus
@ 2002-11-14 21:56 ` hackob
2002-11-15 14:43 ` FSpecs ichi
2 siblings, 0 replies; 6+ messages in thread
From: hackob @ 2002-11-14 21:56 UTC (permalink / raw)
To: linux-newbie
Use cut and/or gawk
----- Original Message -----
From: "BEN RITCHEY" <linux-net@tcob1.net>
To: <linux-newbie@vger.kernel.org>
Sent: Thursday, November 14, 2002 2:56 AM
Subject: FSpecs
> Originally to: ALL
>
> Would it be possible in a Bash script to munge a Long File Name to the
older
> DOS 8.3 format?
>
> In my case I need the first 8 characters and the last 4 (.xxx) ... the
> resulting string would then be used as an argument for another command. :)
>
> --
> Keep the faith,
>
> : Ben http://bellsouthpwp.net/c/m/cmech617 ICQ #32457590
> :
> + WildCat! Board 24/7 (337) 232-4155 33.6kBps 8,N,1 Files!
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.linux-learn.org/faqs
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: FSpecs
2002-11-15 14:43 ` FSpecs ichi
@ 2002-11-15 2:57 ` Ray Olszewski
[not found] ` <3DD54770.6EFEAF21@ihug.co.nz>
0 siblings, 1 reply; 6+ messages in thread
From: Ray Olszewski @ 2002-11-15 2:57 UTC (permalink / raw)
To: linux-newbie
All the approaches suggested for this exercise assume that one need not
worry about generating a UNIQUE 8.3 filename from the long filename. Is
that assumption appropriate to Ben's real, underlying problem? Or does it
risk overwriting a file with a later one (e.g., shortnam-abcd.txt and
shortnam-efgh.txt both become shortnam.txt)?
At 02:43 PM 11/15/02 +0000, ichi@ihug.co.nz wrote:
>BEN RITCHEY wrote:
> >
> > Would it be possible in a Bash script to munge a
> > Long File Name to the older DOS 8.3 format?
> > In my case I need the first 8 characters and the
> > last 4 (.xxx)
>
>To which Paul Kraus replied:
> > It would be a lot easier to do it with gawk or perl.
>
>And hackob said:
> > Use cut and/or gawk
>
>Actually guys, all you need is bash:
>--------------------------------------------------
>example="long-filename.to.munge.txt"
>echo ${example%${example#????????}}.${example##*.}
>--------------------------------------------------
--
-------------------------------------------"Never tell me the odds!"--------
Ray Olszewski -- Han Solo
Palo Alto, California, USA ray@comarre.com
-------------------------------------------------------------------------------
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: FSpecs
2002-11-14 8:56 FSpecs BEN RITCHEY
2002-11-14 21:52 ` FSpecs Paul Kraus
2002-11-14 21:56 ` FSpecs hackob
@ 2002-11-15 14:43 ` ichi
2002-11-15 2:57 ` FSpecs Ray Olszewski
2 siblings, 1 reply; 6+ messages in thread
From: ichi @ 2002-11-15 14:43 UTC (permalink / raw)
To: BEN RITCHEY; +Cc: linux-newbie
BEN RITCHEY wrote:
>
> Would it be possible in a Bash script to munge a
> Long File Name to the older DOS 8.3 format?
> In my case I need the first 8 characters and the
> last 4 (.xxx)
To which Paul Kraus replied:
> It would be a lot easier to do it with gawk or perl.
And hackob said:
> Use cut and/or gawk
Actually guys, all you need is bash:
--------------------------------------------------
example="long-filename.to.munge.txt"
echo ${example%${example#????????}}.${example##*.}
--------------------------------------------------
Cheers,
Steven
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: FSpecs
[not found] ` <3DD54770.6EFEAF21@ihug.co.nz>
@ 2002-11-15 20:42 ` ichi
0 siblings, 0 replies; 6+ messages in thread
From: ichi @ 2002-11-15 20:42 UTC (permalink / raw)
To: linux-newbie
Ray Olszewski wrote:
>
> > > In my case I need the first 8 characters and the
> > > last 4 (.xxx)
> >
> >--------------------------------------------------
> >example="long-filename.to.munge.txt"
> >echo ${example%${example#????????}}.${example##*.}
> >--------------------------------------------------
>
> All the approaches suggested for this exercise assume that one
> need not worry about generating a UNIQUE 8.3 filename from the
> long filename. Is that assumption appropriate to Ben's real,
> underlying problem? Or does it risk overwriting a file with a
> later one
OK, Ray, here's one off the top of my head. I'm sure it
can be improved, but it will do for a start.
-------------------------------------------------------------
#!/bin/bash
from="/home/ichi" to="/tmp"
for i in `ls $from` ; do
front=${i%.*} ; back=""
echo $i | grep "\." >/dev/null ; [ $? = 0 ] && back=.${i##*.}
[ ${#front} -gt 8 ] && front=${front%${front#????????}}
[ ${#back} -gt 4 ] && back=${back%${back#????}}
front=`echo $front | tr " ." "__"`
new=$front$back
for j in `ls $to` ; do
case $j in $new)
echo "$new already exists. Input new name."
read new
esac
done
echo $new ### YOUR OUTPUT ROUTINE GOES HERE ###
done
--------------------------------------------------------------
I suppose somebody is going to tell that there is a built-in
command that does this automatically. Ah, well.
Cheers,
Steven
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2002-11-15 20:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-14 8:56 FSpecs BEN RITCHEY
2002-11-14 21:52 ` FSpecs Paul Kraus
2002-11-14 21:56 ` FSpecs hackob
2002-11-15 14:43 ` FSpecs ichi
2002-11-15 2:57 ` FSpecs Ray Olszewski
[not found] ` <3DD54770.6EFEAF21@ihug.co.nz>
2002-11-15 20:42 ` FSpecs ichi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.