Hi birei,
I have one config directory->*.cfg files(under many .cfg files) and i have one temp input file like->configuration.cfg file,hold..
Code:
filename=monitor.cfg
sectionname=[PROCESS]
p1
p2
filename=ABC.cfg
sectionname=[XYZ]
p3
p4..
so on..
Then i have main script,which read from temp input file line by line,first filename then section name under config dirctory,then for file then for section,if section exist,then it adds parameter exactly enf of section and if section is not found then it's treated as new section and add the whole section with parameter's at end of the file.
Below is my code.....(it's working but it added parameter's in begin of section)..
Code:
while read cfgfilename sectionname parameter
do
case "$cfgfilename" in
cfgfilename)
FILE=$HOME/config/$parameter
unset SECT
[-f $FILE] || {echo -e $FILE is not found under config directory...} | tee -a $LOGFILE
;;
sectionname)
[-z $FILE] && continue
SECT="$parameter"
while true
do
N=$(grep -Fwnx "$SECT" $FILE | cut -d ':' -f1)
((N)) && break
echo -e $SECT section not found in $FILE ,adding section | tee -a $LOGFILE
echo -e "$SECT\n" >> $FILE
done
;;
*)
if [-n "$FILE"] && [-n "$SECT"]
then
((N++))
sed -i"{$N}" 'i\' "$cfgfilename $sectionname $parameter" $FILE
I'm trying to create a reverse lookup file. Below are the error messages I get in the messages file, when I start named. Below the error messages is a copy of the reverse lookup file I'm trying to use. I'm using Bind version 8.1.2. Would someone recommend the correct values and if you see any... (2 Replies)
I a file with log entries... I want to sort it so that the last line in the file is first and the first line is last..
eg.
Sample file
1
h
a
f
8
6
After sort should look like
6
8
f
a
h
1 (11 Replies)
I have to extract data from a text file which is huge in size >>10GB.
ie between two strings. If I do an ordinary sed it takes forever to come out. I was wondering if there was anyway to do the entire process in reverse and on finding the relevant string is there any way to break out of the... (5 Replies)
I've got hundreds of lines in a file that looks like this:
Line1 CCR CCH
Line2 ICVM FBO GSC
Line3 MKF
The result should be like the one below so that I can insert them on our database.
Line1 CCR
Line1 CCH
Line2 ICVM
Line2 FBO
Line2 GSC
Line3 MKF
Thanks in advance! (4 Replies)
Hi Guys,
Am new to this forum .... And also to shell scripting
I need a k-shell script to reverse the contents of a file...
Please come up with the solutions...
With regards,
Anand (10 Replies)
Hi all
I am trying to numerically reverse sort a file but I seem to be having trouble.
Example of file contents:
text1,1
text2,-1
text3,0
I can sort using sort -k 2n -t, filename without any problems.
However I want my results in descending order but using -r in my command... (2 Replies)
without using conventional file searching commands like find etc, is it possible to locate a file if i just know that the file that i'm searching for contains a particular text like "Hello world" or something? (5 Replies)
Hi all,
I have a file named file1as
07/25 00:10 d327490
07/25 00:55 d378299
07/25 03:58 d378299
07/25 06:14 d642035
07/25 12:44 c997126
and now i want to reverse the first filed ie 07/25 as
25/07 00:10 d327490
25/07 00:55 d378299
25/07 03:58 d378299
25/07 06:14 d642035
25/07... (5 Replies)
Hi all,
Just saw a "sed" format to reverse display the file contents, but am not geting its logic completely. I would appreciate if somebody can explain
sed '1!G;h;$!d' < filename
All I know in this is that :
G will add a new line after every line except first one... (5 Replies)