Solved

list only files WITHOUT an extension

Posted on 1998-07-30
6
227 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
LINUX ZIP - UNCOMPRESS WINDOWS PATH 3 88
unix solaris snoop command 6 85
add some character at the end of line in vi 7 63
Martian Packets Unix 5 31
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…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

895 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now