- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Can you explain why it shows myfile twice in the l...
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
06-23-2008 10:34 PM
06-23-2008 10:34 PM
Can you explain why it shows myfile twice in the last command?
test:/tmp > mkdir test
testp > cd test
test:/tmp/test > touch .myfile
test:/tmp/test > ls -al
total 464
drwxr-x--- 2 lsapas6 lsapuser 512 24 Jun 06:44 .
drwxrwxrwt 44 bin bin 230912 24 Jun 06:44 ..
-rw-r----- 1 lsapas6 lsapuser 0 24 Jun 06:44 .myfile
test:/tmp/test > ls -l .* | grep myfile
-rw-r----- 1 lsapas6 lsapuser 0 24 Jun 06:44 .myfile
test:/tmp/test > ls -al .* | grep myfile
-rw-r----- 1 lsapas6 lsapuser 0 24 Jun 06:44 .myfile
-rw-r----- 1 lsapas6 lsapuser 0 24 Jun 06:44 .myfile
Thanks,
Avinash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2008 10:45 PM
06-23-2008 10:45 PM
Re: Can you explain why it shows myfile twice in the last command?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2008 10:47 PM
06-23-2008 10:47 PM
Re: Can you explain why it shows myfile twice in the last command?
To continue my post.
"." is the current directory. So when it lists the contents of the current directory it will disply ".myfile" again when using ls -al .*
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2008 10:52 PM
06-23-2008 10:52 PM
Re: Can you explain why it shows myfile twice in the last command?
test:/tmp/test > ls -al .*
(leave the "grep" away).
You will see that the system is doing the following:
# ls -al
# ls -al .
# ls -al ..
Hope this helps!
Regards
Torsten.
__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.
__________________________________________________
No support by private messages. Please ask the forum!
If you feel this was helpful please click the KUDOS! thumb below!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2008 11:03 PM
06-23-2008 11:03 PM
Re: Can you explain why it shows myfile twice in the last command?
ls -al .[a-z]* |grep myfile works. is it possible to escape "." in .* ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2008 11:08 PM
06-23-2008 11:08 PM
Re: Can you explain why it shows myfile twice in the last command?
ll |grep \\.m
Regards,
Rasheed Tamton.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2008 11:14 PM
06-23-2008 11:14 PM
Re: Can you explain why it shows myfile twice in the last command?
ll|awk '{print $9}'|grep ^\\.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2008 11:20 PM
06-23-2008 11:20 PM
Re: Can you explain why it shows myfile twice in the last command?
ls -al .[[:alnum:]]*
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2008 11:25 PM
06-23-2008 11:25 PM
Re: Can you explain why it shows myfile twice in the last command?
No need to escape "." in the Pattern Matching Notation that the shell uses. There "?" is the any char, character. You would have to escape it in grep's Basic Regular Expression.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2008 11:27 PM
06-23-2008 11:27 PM
Re: Can you explain why it shows myfile twice in the last command?
this is the reason why you see the file twice.
It is a result of
# ls -al
followed by
# ls -al .
Both commands find the file.
Hope this helps!
Regards
Torsten.
__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.
__________________________________________________
No support by private messages. Please ask the forum!
If you feel this was helpful please click the KUDOS! thumb below!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2008 12:13 AM
06-24-2008 12:13 AM
Re: Can you explain why it shows myfile twice in the last command?
Explanation as follows:
1)Ur command ls -al .* | grep myfile
Shell is executing command in following way.
ls - list
l - long list
a - hidden files
now ls -al .* will show all hidden files as well as hidden directories from current working directory.
1) So as per execution of command,shell will find â .â Directory (i.e. Current directory - /tmp/test)
U have issued log listing, so it will show files & directory tree inside â .â means current directory /tmp/test. There again u have greped for .myfile, so it will show u .myfile.
So thatâ s ur first o/p â -rw-r----- 1 lsapas6 lsapuser 0 24 Jun 06:44 .myfileâ
2) Now shell will go to next directory i.e. â ..â (Parent directory-/tmp in ur case)
But there is no .myfile in /tmp.
So, It will go to next dir or file.
In case of dir it will search for .myfile & goes to next dir/file
In case of file it will matches it with .myfile,it equals to .myfile,it will return result as
So thatâ s ur second o/p â -rw-r----- 1 lsapas6 lsapuser 0 24 Jun 06:44 .myfileâ
So this is the reason why it is showing .myfile twice as in Present working directory & â .â means Current working directory.
And Present working directory & Current working directory is same i.e.
/tmp/test
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2008 09:02 AM
06-27-2008 09:02 AM
Re: Can you explain why it shows myfile twice in the last command?
the simpiliest way to overcome this IMHO:
ls -ld .* | ...
ls -ald .* | ... (but this won't tell anything different)
mfG Peter