*sigh* sed help needed

*sigh* sed help needed

Post by Timothy J. Luom » Mon, 14 Aug 1995 04:00:00



Ok, this is probably laughable for someone who knows sed, but I can't
hack the syntax (no pun intended)

here's my problem (the current one ;-)

I have a bunch of folders containing applications, in the form of:

Someapp.app
Somethingelse.app
anotherone.app

I want to get a list of all of them, so I 'ls' each directory which has
these applications, and get a list of them.

So far so good.  But what I end up with is a list WITH the ".app" at the
end of each, and what I want is a list WITHOUT the ".app".

I figured a microsecond in 'sed' would do it, but I haven't been able to
figure out the way to tell sed what I want to do

any suggestions appreciated

TjL

--

NeXT 3.2 m68k                   Just another convert to the Z-Shell
"If I  understood the man page, I wouldn't have asked the question."

 
 
 

*sigh* sed help needed

Post by David W. Tamk » Mon, 14 Aug 1995 04:00:00




| here's my problem (the current one ;-)
|
| I have a bunch of folders containing applications, in the form of:
|
| Someapp.app
| Somethingelse.app
| anotherone.app
|
| I want to get a list of all of them, so I 'ls' each directory which has
| these applications, and get a list of them.
|
| So far so good.  But what I end up with is a list WITH the ".app" at the
| end of each, and what I want is a list WITHOUT the ".app".
|
| I figured a microsecond in 'sed' would do it, but I haven't been able to
| figure out the way to tell sed what I want to do

Something is unclear: do the NAMES of those files include the ".app" suffix
that you want to get rid of, or do the CONTENTS of those files have it?

To get it off the names,

        ls | sed 's/\.app$//'

Some very odd ls's may require this:

        ls -1 | sed 's/\.app$//'

 
 
 

*sigh* sed help needed

Post by Spid » Mon, 14 Aug 1995 04:00:00



Quote:>I have a bunch of folders containing applications, in the form of:
>Someapp.app
>Somethingelse.app
>anotherone.app
>I want to get a list of all of them, so I 'ls' each directory which has
>these applications, and get a list of them.
>So far so good.  But what I end up with is a list WITH the ".app" at the
>end of each, and what I want is a list WITHOUT the ".app".

If you *really* want to use sed you could use this:

ls -1 *.app | sed 's/\.app$//' >> file_list

The '$' guarantees that the string '.app' will be removed only with it appears
at the end of a line.  Note that if you have mixed case extensions (.App or
.APP) you'll have to use

ls -1 *.[Aa][Pp][Pp] | sed 's/\.[Aa][Pp][Pp]$//' >> file_list

However, if you know for sure that '.app' is always in lowercase you could
use the following, which is a little less complicated:

#!/bin/sh
# List all files in the current directory that end in .app without the suffix.
for file in *.app
do
basename $file .app
done >> file_list

Or if you have ksh, the best choice is this one:

#!/bin/ksh
# List all files in the current directory that end in .app (regardless of
# case) with the suffix stripped away.
for file in *.[Aa][Pp][Pp]
do
print ${file%*.[Aa][Pp][Pp]}
done >> file_list

---

 
 
 

*sigh* sed help needed

Post by Jeff Orans » Tue, 15 Aug 1995 04:00:00




>Subject: *sigh* sed help needed
>Date: Sun, 13 Aug 1995 15:31:27 -0400
>Ok, this is probably laughable for someone who knows sed, but I can't
>hack the syntax (no pun intended)
>here's my problem (the current one ;-)
>I have a bunch of folders containing applications, in the form of:
>Someapp.app
>Somethingelse.app
>anotherone.app
>I want to get a list of all of them, so I 'ls' each directory which has
>these applications, and get a list of them.
>So far so good.  But what I end up with is a list WITH the ".app" at the
>end of each, and what I want is a list WITHOUT the ".app".
>I figured a microsecond in 'sed' would do it, but I haven't been able to
>figure out the way to tell sed what I want to do
>any suggestions appreciated

You could also use cut, like this:

ls *.app | cut -d'.' -f1

The -d option tells cut that the delimiter of the input file (the ls output)
is a period.  Cut will then cut the first field based on this delimiter (the
base name of the file).

Jeff

 
 
 

1. vmstat | sed WORKS vmstat | logger WORKS vmstat | sed | logger FAILS - NEED HELP

I am using FreeBSD 3.3.

The following two pipes work fine:

vmstat -w 5 | logger -p local0.info
vmstat -w 5 | sed -e /procs/d -e /fre/d

But don't work when combined into:

vmstat -w 5 | sed -e /procs/d -e /fre/d | logger -p local0.info

I don't understand why.  Any suggestions?

2. Help needed for FTP install-RH5.1

3. Sigh, Red Hat help needed

4. History keys in linux

5. sed sed sed

6. bosboot/mksysb

7. . 2 sed FAQs, sed exes, sed cetras; URLs

8. Wanted: Wyse 7000i series....

9. SED SED SED...

10. (sed 1q ; sed 2q) : no output from 2nd 'sed'

11. Need help from sed guru

12. sed and awk help needed

13. Help needed with SED problem