Solved

how to list files without extention

Posted on 2001-07-20
7
337 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
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 
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

Independent Software Vendors: 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…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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 navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

690 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