Solved

list only files WITHOUT an extension

Posted on 1998-07-30
6
259 Views
Last Modified: 2010-04-21
I have .pc sources and compiled executables in the same dir.
I want to make links to the executables for a run directory like:
ln c_progs/*????  $rundir

How to make the ln create links for the PROGEXE files and not the PROGEXE.pc files ?
If the solution is :
ln c_progs/*[!.][!p][!c]*
then what shell should I be in, it does not seem to work for me.
0
Comment
Question by:kphallpa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 

Author Comment

by:kphallpa
ID: 2009180
Edited text of question
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 100 total points
ID: 2009181
ls | grep -v '\.'

To create you links in csh:

  foreach f (`ls c_progs/*|grep -v '\.pc$'`)
    ln -s $f $rundir
    end
0
 

Author Comment

by:kphallpa
ID: 2009182
Thanks for your reply.
However, does this mean that there is no straight-forward way of listing only files without an extension using regular expressions ?

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 51

Expert Comment

by:ahoffmann
ID: 2009183
No, it doen't mean that it is not possible with reg exps.

You're doing 2 jobs:
  1. list all files with speciafired atributes (no extension)
  2. perform a link to these files
so you question sounds simple, and UNIX has simple programs to do
simple and/or sophisticated things, usually on task - one program
(as you see here :-))

If you worry about the  foreach, you also may find a solution using pipes:

   ls c_progs/*|sed -e 's/\([^\.]*\).pc$/ln -s \1 '$rundir'/'|sh

(NOTE: that the sed may not filter off all unwanted files)
(NOTE 2: on some UNIXs it may crash with "Argument too long").

Feel free to ask more ..
0
 

Author Comment

by:kphallpa
ID: 2009184
Thanks for your help. Both solutions are suitable.
I realise that UNIX doesn't care about extensions anyway, it is just a filename with a dot instead of another character.
It is just human nature to try to make it do more than it was designed for.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 2009185
> It is just human nature to try to make it do more than it was designed for.

Hmm, this could start a philosophical discusion about "what is human and what is M$" :-))

I.g. in UNIX there are exactly 4 restrictions for filenames (beside some OS-dependant restrictions in length):
  1. must not contain /
  2. must not contain null
  3. must not be  .
  4. must not be  ..

Any other ASCII character, printable or not, is a valid char in any combination. Easy, isn't it ?
Of course this is, in most cases, to easy for a lot of programs. So it's best to limit the range of characters to [a-zA-Z0-9_,.-+=] . And some programs even expect that there is only one  .  in the filename.

Have fun with UNIX.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question