Solved

list only files WITHOUT an extension

Posted on 1998-07-30
6
217 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
Comment Utility
Edited text of question
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 100 total points
Comment Utility
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
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
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
Comment Utility
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
Comment Utility
> 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
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.

771 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

9 Experts available now in Live!

Get 1:1 Help Now