?
Solved

list only files WITHOUT an extension

Posted on 1998-07-30
6
Medium Priority
?
265 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 200 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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…
Suggested Courses

752 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