- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Remove a comment # from a 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
Forums
Discussions
Discussions
Forums
Discussions
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
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
10-06-2003 04:08 AM
10-06-2003 04:08 AM
I think I am half way the problem as I believe I should use ch_rc command, but I am not sure of the syntax.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2003 04:12 AM
10-06-2003 04:12 AM
Re: Remove a comment # from a file
sed 's|#AnyOtherTextNecessaryToIdentifyTheLine||g'`
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2003 04:17 AM
10-06-2003 04:17 AM
Re: Remove a comment # from a file
Regards,
Sergejs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2003 04:34 AM
10-06-2003 04:34 AM
Re: Remove a comment # from a file
"/etc/rc.config.d/savecrash" and remove the comments from three lines and the sed allow you to only create it on anew file. So, I am trying to save multiple steps.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2003 04:46 AM
10-06-2003 04:46 AM
Re: Remove a comment # from a file
sed 's/#//n' infile > outfile
(n=1 to 512). Substitute for just the n'th occurrence.
Bruno
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2003 04:52 AM
10-06-2003 04:52 AM
Re: Remove a comment # from a file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2003 05:13 AM
10-06-2003 05:13 AM
Re: Remove a comment # from a file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2003 08:26 AM
10-06-2003 08:26 AM
Re: Remove a comment # from a file
-----------------------------
open I, $ARGV[0] or die "cannot open $ARGV[0]: $!";
while ($line=)
{
next if $line=~ /^#/;
print $line;
}
------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2003 01:02 AM
10-07-2003 01:02 AM
Re: Remove a comment # from a file
# SAVECRASH=1
# SAVECRASH_DIR=/var/adm/crash
# COMPRESS=2
I know how to change the values using
#ch_rc -a -p
and on the man pages it says you can remove characters also, but I am not sure How ?
I appreciate your responses.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2003 01:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2003 01:15 AM
10-07-2003 01:15 AM
Re: Remove a comment # from a file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2003 01:18 AM
10-07-2003 01:18 AM
Re: Remove a comment # from a file
You need to use "vi", "emacs" or "ed". Unless you are a pattern matching expert and know how to write code in perl, your request for another "answer", other than editors, is highly unlikely, especially since you want to have an answer that magically knows which "#" lines to remove or possibly "un-comment" lines and which not to.
If you don't like "vi", then copy the progam to your desktop and use "wordpad".
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2003 01:19 AM
10-07-2003 01:19 AM
Re: Remove a comment # from a file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2003 01:25 AM
10-07-2003 01:25 AM
Re: Remove a comment # from a file
I tend to agree with Harry.
In addition, if you just want to get rid of consecutive lines at the beginning or at the end of the file, you can use head and/or tail. For instance, you want the 4th line onwards from the file, then:
# tail +4 myfile > myfile2
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2003 01:27 AM
10-07-2003 01:27 AM
Re: Remove a comment # from a file
If it is something you find you are doing a lot of just make a copy of the file with the comments in and another with the comments out and just cp the one you want when you want.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2003 01:41 AM
10-07-2003 01:41 AM
Re: Remove a comment # from a file
I will use Mark's solution
cat savecrash.prev | sed s/^#//g > savecrash
and specify each line.
Thanks again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2003 04:26 AM
10-07-2003 04:26 AM
Re: Remove a comment # from a file
then you can use vi
this way
create "mycom" a command file :
:1,$s/^# SAVECRASH/SAVECRASH/
:wq
then run
vi
Rgds,
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2003 08:09 PM
10-07-2003 08:09 PM
Re: Remove a comment # from a file
cat savecrash | sed s/# SAVECRASH//g > savecrash.tmp
cat savecrash.tmp | sed s/# COMPRESS//g > savecrash
P.S. option g=globale or n=occorrence
HTH
Bruno
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2003 08:12 PM
10-07-2003 08:12 PM
Re: Remove a comment # from a file
Well, try
cat savecrash | sed s/# SAVECRASH/SAVECRASH/g > savecrash.tmp
cat savecrash.tmp | sed s/# COMPRESS/COMPRESS/g > savecrash
P.S. option g=globale or n=occorrence
HTH
Bruno