[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

how to list files without extention

Posted on 2001-07-20
7
Medium Priority
?
347 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
Technology Partners: 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

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
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…
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.
Suggested Courses

834 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