Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Trying to show lines in INI files until the comment character (#) Post 302454487 by hindesite on Saturday 18th of September 2010 02:13:07 PM
Old 09-18-2010
Trying to show lines in INI files until the comment character (#)

I have a working directory on a server with over 100 INI files. For the most part, they are configured the same way. Each line will contain 1 or none variables listed from the first character in the line such as VariableName=0.

Unfortunately there are comments everywhere using the poundsign.

I have created a looping grep - I grep all files for one particular variable - so that all of the same settings in the files are stacked one upon the other for easy review. Then the loop move to the next variable name in my list.

My problem is this. I use the following line to omit where the comment text might state directions to set the variable = this or that for these reasons:

Code:
grep $varEQ *.ini | grep -v '#' >> /tmp/ini_FTP_settings_$INTFC.lst;

This blocked lines where the vaiable was set and then a comment was appended in the line of text after the variable was set, such as

Code:
VariableZ=0     # Remember to never set this variable to 1.

This is probably a newbie type question, but how do I bring back the VariableZ=0 portion and nothing after the # sign? If the pound sign is the first character in a line, I don't want to report any of that line either.

Any help would be appreciated.

- Dann "hindesite" Hindes
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to comment multiple lines in unix

hi all, please help me how to comment multiple lines in unix script. thanks in advance --bali (3 Replies)
Discussion started by: balireddy_77
3 Replies

2. UNIX for Dummies Questions & Answers

comment lines

Is there a command to put a comment (#) in a whole part of a shell script? (5 Replies)
Discussion started by: vero_81
5 Replies

3. Shell Programming and Scripting

script assistance needed - create an archive of INI files

First and foremost - me != unix bubba. Here is the situation. We have a box with data AND settings in the same directory path. (Data files aren't in the SAME directories as settings.) I need a script that generates a tarred-up archive of only the INI files with the directory structure. We... (2 Replies)
Discussion started by: hindesite
2 Replies

4. Shell Programming and Scripting

sed show lines text between 2 blank lines

I have a file like blah blah blah blah this is the text I need, which might be between 1-4 lines, but always has a blank line above and below it, and is at the end of the text file the code tags don't show the trailing blank line. I started by deleting the last blank line with: ... (2 Replies)
Discussion started by: unclecameron
2 Replies

5. Shell Programming and Scripting

How can i comment out a section between two particular lines

I want to find out which files under /etc have the the following section: and then i would like to comment out the above section in all the files. Please help. (3 Replies)
Discussion started by: proactiveaditya
3 Replies

6. Shell Programming and Scripting

Comment lines in FSTAB using perl

Hi All, I need to comment specific Two Lines in fstab & want to do using & also want to ensure that is done corretly. I am trying the below method. But its giving Search pattern not terminated. ################ b36376 67 % cat linux-fstab_testing | perl -i -wnl -e '/^('\Q... (1 Reply)
Discussion started by: ajaincv
1 Replies

7. UNIX for Dummies Questions & Answers

Comment lines in file without vi editor

Legends, Can you please help me in following. I need to comment lines from “/tmp/a.txt” from the line A to line B through the command prompt only. Please use variables not direct values like 2 or 5 It can be done with VI editor but it's not matches with my requirement (: 2,5 s/^/#/g). ... (1 Reply)
Discussion started by: sdosanjh
1 Replies

8. UNIX for Dummies Questions & Answers

Append two lines of text to php.ini in the entire directory tree.e

I am looking to write a script that will read the php.ini files on my web host. If the two lines do exist do nothing. If not append two lines to the end of it then move on to the next directory and open the next php.ini file. I have the beginning of one that was given to me on another web site but... (6 Replies)
Discussion started by: Larrykh465
6 Replies

9. Shell Programming and Scripting

Bash: copying lines with specific character to files with same name as copied line.

I am trying to make my script as simple as a possible but, I am not sure if the way I am approaching is necessarily the most efficient or effective it can be. What I am mainly trying to fix is a for loop to remove a string from the specified files and within this loop I am trying to copy the lines... (2 Replies)
Discussion started by: Allie_gastrator
2 Replies
Config::Any::INI(3)					User Contributed Perl Documentation				       Config::Any::INI(3)

NAME
Config::Any::INI - Load INI config files DESCRIPTION
Loads INI files. Example: name=TestApp [Controller::Foo] foo=bar [Model::Baz] qux=xyzzy METHODS
extensions( ) return an array of valid extensions ("ini"). load( $file ) Attempts to load $file as an INI file. requires_all_of( ) Specifies that this module requires Config::Tiny in order to work. PACKAGE VARIABLES
$MAP_SECTION_SPACE_TO_NESTED_KEY (boolean) This variable controls whether spaces in INI section headings will be expanded into nested hash keys. e.g. it controls whether [Full Power] maps to $config->{'Full Power'} or $config->{'Full'}->{'Power'} By default it is set to 1 (i.e. true). Set it to 0 to preserve literal spaces in section headings: use Config::Any; use Config::Any::INI; $Config::Any::INI::MAP_SECTION_SPACE_TO_NESTED_KEY = 0; AUTHORS
Brian Cassidy <bricas@cpan.org> Joel Bernstein <rataxis@cpan.org> COPYRIGHT AND LICENSE
Copyright 2006-2011 by Brian Cassidy, portions copyright 2006, 2007 by Joel Bernstein This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
o Catalyst o Config::Any o Config::Tiny perl v5.16.2 2011-05-24 Config::Any::INI(3)
All times are GMT -4. The time now is 01:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy