- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Advanced ksh shell help.
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2005 04:15 PM
11-23-2005 04:15 PM
Advanced ksh shell help.
root.old
xync
xdr.cdb
port.ory
port
abc
I tried following.
ll [a-zA-Z]*[!\.][a-zA-Z]*
ll *[!\.]*
and fe other combinations.
Thank you in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2005 04:26 PM
11-23-2005 04:26 PM
Re: Advanced ksh shell help.
ll | grep -v '\.'
I would have to think a little more about the
regexp solution.
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2005 04:39 PM
11-23-2005 04:39 PM
Re: Advanced ksh shell help.
seems to work:
ll [a-zA-Z][!\.]
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2005 04:46 PM
11-23-2005 04:46 PM
Re: Advanced ksh shell help.
That does not work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2005 06:55 PM
11-23-2005 06:55 PM
Re: Advanced ksh shell help.
# ll | grep -v '\.'
You need to take care to protect the \. from the shell, e.g. using ''.
Or simply use fgrep:
# ls -l | fgrep -v .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2005 08:08 PM
11-23-2005 08:08 PM
Re: Advanced ksh shell help.
As Dietmar's advise would be solution.
ls -l | fgrep -v .
good luck,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2005 08:10 PM
11-23-2005 08:10 PM
Re: Advanced ksh shell help.
* is the problem in using with ls command.
ll [a-zA-Z]*
it is not meaning that,
only a to z A to Z -- 0 or more times.
It is meaning as,
one a to z or A to Z in the beginning. Anything after that. It is including . 0-9 - + etc in that.
Example:
# ls -l [a-z]
-rw-rw-rw- 1 root sys 0 Nov 23 23:54 a
# ls -l [a-z]*
-rw-rw-rw- 1 root sys 0 Nov 23 23:54 a
-rw-rw-rw- 1 root sys 0 Nov 23 23:35 bye
-rw-rw-rw- 1 root sys 0 Nov 23 23:35 file1.
-rw-rw-rw- 1 root sys 0 Nov 23 23:35 ok.ksh
-rw-rw-rw- 1 root sys 0 Nov 24 01:38 ok_bye
-rw-rw-rw- 1 root sys 0 Nov 23 23:35 test.sh
To remove . then we must not use *. We have to handle it specifically as,
ls -l [a-z][a-z][a-z][!\.]*
ls -l [a-z][a-z][a-z][a-z][!\.]*
To avoid this you can with grep or awk as,
ls -l | grep -v '\.'
ls -l | awk '!/\./ { print; }'
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2005 10:04 PM
11-23-2005 10:04 PM
Re: Advanced ksh shell help.
# ls -l | grep -v "[.]"
should also work.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2005 10:39 PM
11-23-2005 10:39 PM
Re: Advanced ksh shell help.
While grep -v will what I want I wanted to use above pattern matching.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2005 11:35 PM
11-23-2005 11:35 PM
Re: Advanced ksh shell help.
I think it will be quite difficult, as the pattern you want to specify should work on file name expansion directly.
This means that if you expand to a directory name and that directory holds a filename like the ones you specify, they are listed and not filtered out, as they would be if the above "grep" examples were used; these will work on the actual output of the commands.
I have tried with this terrible pattern:
# ls !([a-zA-Z0-9]*[.]*[a-za-Z0-9]*|[.]*{a-zA-Z0-9]|[a-zA-Z0-9]*[.]$)
which I hardly understand any longer myself, but if it matches a dir holding one of your files, the file will of course be listed.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2005 11:38 PM
11-23-2005 11:38 PM
Re: Advanced ksh shell help.
for FILE in `ls`; do echo $FILE | awk -F "." 'NF==1 {print $0}';done
You can then customize the first ls to use the patters that you want.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2005 07:24 PM
11-24-2005 07:24 PM
Re: Advanced ksh shell help.
# ls !([a-zA-Z0-9]*[.]*[a-za-Z0-9]*|[.]*{a-zA-Z0-9]|[a-zA-Z0-9]*[.]$)
solution will list all files (including . dotted files).
If we use * with ls it will everything. It is not like [a-z]* means to take a to z 0 to more times. It is taking as one a to z and anything other.
We must not use *. We have to go with specific thing as in my previos reply.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2005 07:57 PM
11-24-2005 07:57 PM
Re: Advanced ksh shell help.
sorry, it should be:
# ls !([a-zA-Z0-9]*[.]*[a-za-Z0-9]*|[.]*{a-zA-Z0-9]|[a-zA-Z0-9]*[.])
and I think that it does not list the names of files with dots in the file name in the *current* directory.
Hoever, as the command also lists directory names, the files under those will be listed as they are and not filtered by grep.
Does the command list dot filenames in the "current directory" on your system?
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2005 08:07 PM
11-24-2005 08:07 PM
Re: Advanced ksh shell help.
It does not work. I think 8 makes all difference.
ll !([a-zA-Z0-9]*[.]*[a-za-Z0-9]*|[.]*[a-zA-Z0-9]|[a-zA-Z0-9]*[.])
-r-------- 1 root users 749 Nov 4 10:18 capplan
-r-------- 1 capplan users 398 Jul 9 2004 capplan.old
-r-------- 1 root dba 6303 Nov 22 13:50 oracle
-r-------- 1 oracle dba 4833 Aug 27 2004 oracle.old
-r-------- 1 root dba 0 Apr 12 2005 precise
-r-------- 1 root sys 3819 Jul 23 01:14 root
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2005 08:15 PM
11-24-2005 08:15 PM
Re: Advanced ksh shell help.
We may not get . negated files using ls -l
If you want to negate only . dotted files then,
# alias lsn='ls -l | grep -v "\."'
# lsn
that is all. ;)
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2005 09:42 PM
11-24-2005 09:42 PM
Re: Advanced ksh shell help.
my example is for the ls command - not ll.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2005 09:56 PM
11-24-2005 09:56 PM
Re: Advanced ksh shell help.
See this:
# ls
a file1 file1.sh file2 file_ok test.tar
#
#
# ls !([a-zA-Z0-9]*[.]*[a-za-Z0-9]*|[.]*{a-zA-Z0-9]|[a-zA-Z0-9]*[.])
a file1 file1.sh file2 file_ok test.tar
#
Can you clarify here.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2005 10:51 PM
11-24-2005 10:51 PM
Re: Advanced ksh shell help.
maybe I should have said that I executed
# sh
first, and then:
# ls
a file1 file1.sh file.2 file_ok test.tar
# ls !([a-zA-Z0-9]*[.]*[a-za-Z0-9]*|[.]*{a-zA-Z0-0-9]|[a-zA-Z0-9]*[.])
a file1 file_ok
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2005 12:09 AM
11-25-2005 12:09 AM
Re: Advanced ksh shell help.
how about this:
ls
abc port port.ory root.old xdr.cdb xync
ls -d !(*.*)
abc port xync
mfG Peter