Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

list only files WITHOUT an extension

Posted on 1998-07-30
6
Medium Priority
?
270 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
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 find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses

618 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