Solved

how to list files without extention

Posted on 2001-07-20
7
320 Views
Last Modified: 2013-12-27
Under Solaris I want to list files without extention

For example, I have the following files


a
a.b
a.b.c


How can i list files without extention

a

How can i list files with one extention

a.b

How can i list files with two extention

a.b.c

thx
0
Comment
Question by:Phoebe
7 Comments
 
LVL 3

Expert Comment

by:interiot
ID: 6303559
alias lsn ls \| perl -nle \''print if /^[^.]*(\.[^.]*){\!:1}$/'\'

(in csh/tcsh anyway)

Files with no extension:
  lsn 0
Files with 2 extensions:
  lsn 2

0
 

Author Comment

by:Phoebe
ID: 6303717
No perl install in our box?

How to get it resolved?
0
 
LVL 3

Expert Comment

by:interiot
ID: 6303802
Check /usr/misc/bin/perl?

The following alias seems to work for gnu grep, but very everything except for zero.

   alias lsn ls \| grep \''^[^.]*\(\.[^.]*\)\{\!:1\}$'\'
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 51

Expert Comment

by:ahoffmann
ID: 6304438
ls | gawk -F. -v OFS=. '(NF==1){print};'
ls | gawk -F. -v OFS=. '(NF==2){print};'
ls | gawk -F. -v OFS=. '(NF==3){print};'
...
0
 
LVL 5

Accepted Solution

by:
paulqna earned 50 total points
ID: 6306170
Like this (any shell)


How can i list files without extention

$ ls | cut -d. -f1


How can i list files with one extention

$ ls | cut -d. -f1,2


How can i list files with two extention

$ ls | cut -d. -f1,2,3
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6306334
>How can i list files with X extention
lists files with less than X extension too
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6309701
Phoebe, could you please explain why this answer fits your question.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
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.:
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.

760 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

17 Experts available now in Live!

Get 1:1 Help Now