Thank you for your response but it is not exactly what I want.
I would like that the # comments are written inside the script itself.
These comments are only here to explain the array and are always the same.
The user enters only the four variables 10 20 srv_log srv4 from the third line.
The user can choice the name file.
For example
Quote:
# Please enter the right variable # begin_hour...end_hour.....name_log.....name_server
......10.............20..............srv_log...........srv4
Have a nice day..
---------- Post updated at 06:23 AM ---------- Previous update was at 06:17 AM ----------
I would like too that the script creates the mylogname when
./myscript mylogname
Last edited by amazigh42; 02-09-2013 at 07:21 AM..
Reason: addition tag
To expand on what Skrynesaver used in the code, the man page for egrep has this for egrep -v :
Quote:
-v, --invert-match
Invert the sense of matching, to select non-matching lines. (-v is specified by POSIX.)
So when you tried this:
egrep -v '^#' list_file
Egrep was told to search for all lines that did 'not' begin with a "#" character. Simply removing "-v" parameter would have allowed you to grep out the lines with hashes:
The "-v" parameter works the same way with grep. As you may notice Skrynesaver used -e instead which is used for pattern matching like '^#', but essentially this is the same thing without the "-v".
Just thought I would add this in case you wanted to understand this and know more about how grep and egrep work.
EDIT: Sorry, if this seems out of order. I believe you must have posted while I was typing this.
Last edited by Azrael; 02-09-2013 at 07:31 AM..
Reason: Explaining
It is really unclear what is required. Is the list_file variable or the output file?
You could try something like this and adjust as required...
Sorry Scrutinizer,
You 're right, it's not clear what I said.
I start again.
This my_script.sh
For information
My function f1 is going to grep the lines between 2 hours (10 to 20) and (08 to 10) respectively in srv4's srv_log and srv3's srv_log.
Then this function f1 will put the results into 2 files named srv4.srv_log.10H-20H and srv3.srv_log.08H-10H.
Hello,
I have a SAS code that predominantly has comments line and the real code like below and i want to remove ONLY THE COMMENTS from the code in the single line or spanned across multiple lines.
/********************************************************************
*** This Is a Comment... (4 Replies)
Just began to learn on Shell Script. I got an exercise from my friend. I know how to make this happen in C, but I'm not familiar with Shell Script. Hope I can get some help from all of you.
I want to write a bash script to comment code blocks in a bash source file. What I mean comment is '#', I... (1 Reply)
My first comment on every file contains the license message. I want to replace with a new license message. I used the below sed script, which replaces all comments. What is the modification or any other method with awk script for the below to edit only the first comment(license message)?
#sed -f... (1 Reply)
Hi to all,
I got this content/pattern from file http.log.20110808.gz
mail1 httpd: Account Notice: close igchung@abc.com 2011/8/7 7:37:36 0:00:03 0 0 1
mail1 httpd: Account Information: login sastria9@abc.com proxy sid=gFp4DLm5HnU
mail1 httpd: Account Notice: close sastria9@abc.com... (16 Replies)
Hi,
I am writing a shell script, which should comment a if-fi loop in a file.
From google i found that, we can use below qualifier to comment a section of code,
:<<COMMENT
COMMENT
But i could not place these keywords before and after if-fi loop.
Any help would be appreciated.
Finally the... (2 Replies)
hi,
i need my bash script to find regex in xml file.. and comment 2 lines before and after the line that contains regex.. can't use # needs to be <!-- at the beginning and --> and the end of the comment.
so eg..
first block
<filter>
<filter-name>MyRegEx</filter-name>
... (11 Replies)
Hi guys, hope you scripting gurus here can help me out, the logic in my script somehow not working the way it should, this script part of a bigger backup script suppose to do some checking on the cluster prior to bringing up the package on MC/SG after backend cloning operation, this portion is... (3 Replies)