[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

how to list files without extention

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

 
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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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 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…
Suggested Courses

650 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