- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- how to view the commented line in vi file
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
Discussions
Discussions
Forums
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
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-09-2011 07:37 PM
тАО06-09-2011 07:37 PM
example:
vi sudoers
1.# Cmnd alias specification
2.STORE /usr/sbin/frestore, /usr/sbin/backup
3.UMOUNT = /usr/sbin/umount
4.MOUNT = /usr/sbin/mount
5.# Host alias specification
the above example i want to view the line number 2,3,4 .because i want to see the uncommented line in the vi file
pls help me
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-09-2011 08:42 PM
тАО06-09-2011 08:42 PM
Re: how to view the commented line in vi file
What is "vi file"? A plain-old text file
which was created by "vi"?
> [...] i want to view [...]
Can't you see them now?
Do you mean something like this?:
alp$ grep -v '^#' 1483561.txt
STORE /usr/sbin/frestore, /usr/sbin/backup
UMOUNT = /usr/sbin/umount
MOUNT = /usr/sbin/mount
man grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-09-2011 09:36 PM
тАО06-09-2011 09:36 PM
Re: how to view the commented line in vi file
my request is
in this sudoers file ,i want to view only uncommneted line, how to view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-09-2011 09:44 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-09-2011 09:55 PM
тАО06-09-2011 09:55 PM
Re: how to view the commented line in vi file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-09-2011 10:46 PM
тАО06-09-2011 10:46 PM
Re: how to view the commented line in vi file
Ok, if you want to reject any line with a "#"
in it anywhere. '^#' is a little more
selective.
> [...] only uncommneted line [...]
Define "uncommneted line". Is
/util/search.sh '###' > /tmp/fred.out
an "uncommneted line"?
Everything's complicated, and a vague problem
statement can lead to a sloppy "solution".
> Jun 10, 2011 04:42:59 GMT 8 pts
What? Did I use the wrong file name?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-09-2011 11:43 PM
тАО06-09-2011 11:43 PM
Re: how to view the commented line in vi file
I haven't seen any standard unix configuration files, which would NOT have the '#' at the beginning of the line :) , that's why I'm always using -v '#' .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-10-2011 04:01 AM
тАО06-10-2011 04:01 AM
Re: how to view the commented line in vi file
> configuration files, which would NOT have
> the '#' at the beginning of the line :) ,
> that's why I'm always using -v '#' .
The original question said "vi file"
(whatever that means), not "standard unix
configuration files". However, let's look at
the example of "sudoers". I'm not a big sudo
user, so I know nothing, but a quick Google
search found some documentation which
suggests that "sudoers" might contain
notation like, say,
#include /etc/sudoers.local
which would make this task a little more
chancy. Also, it appears that one is allowed
to use "#" to add a comment to the end of a
normal line, and it seems to be a part of the
"sudoers" syntax, as in "#uid" or "%#gid".
So, discarding any line which contains "#"
anywhere would seem in this example to risk
losing considerable useful information.
If you would like to expand "^#" to include
white space before "#" (and/or "#include" at
the beginning of a line), then I wouldn't
complain.
> Everything's complicated, [...]
A simple solution to a problem is normally
better than a more complicated one, unless
that simpler "solution" doesn't actually
solve the problem. (Of course, having a
clear and complete definition of the problem
is helpful, but this is often difficult to
obtain.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-10-2011 06:14 AM
тАО06-10-2011 06:14 AM
Re: how to view the commented line in vi file
Do a grep -v for all lines starts with # which can be identified using "^#" in the output of the cat command.
cat /etc/sudoers |grep -v "^#"
All lines starts with a # will be eliminated in the output.
todo lo mejor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-10-2011 09:53 AM
тАО06-10-2011 09:53 AM
Re: how to view the commented line in vi file
Why didn't _I_ think of that? No, wait...
Note that the "cat" is not needed.