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:
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
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.
John1212: I think yours has the greatest chance of working. At this point, it does not. When a line is encountered with a pound sign, nothing is returned and appended to my output. (What is appended is the filename: portion of the stdout from grepping across multiple files.) Is there a small sytax error in your sed substitution code? I am not good at sed yet, and would appreciate you looking at it a second time.
Dear hindesite!!
For me, your comment about my chance is unnecessary.
You work though you 'not good at sed yet'.
I recall you, 'grep' you written.
What for do I know that you don't want the name of ini files ?
boy, and so seriously,
who are interested in the existence of the text in the collection of *. ini, and do not want to know where.
Learn. Learn. Learn the logic. Learn about "grep" too.
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)
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)
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)
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)
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)
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)
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)