?
Solved

how to list files without extention

Posted on 2001-07-20
7
Medium Priority
?
343 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
[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
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
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!

 
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 150 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

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

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
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 several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…
Suggested Courses
Course of the Month13 days, 19 hours left to enroll

801 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