Editing files in shell programing


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Editing files in shell programing
# 1  
Old 07-13-2005
Editing files in shell programing

Hi folks,

In our product installation program we edit xml files by deleting lines and appending new lines instead of them.
For example:
update_Log4plsql_xml()
{
machineName=`uname -n`
hostIP=`cat /etc/hosts | grep ${machineName} | cut -f1`

trap 'clean_up | tee -a $installLog ; exit' 1 2 3 4 15 16
echo "\nChecking log4plsql.xml ..." >> $installLog
errMsg="ERROR: unable to add environmental parameter to log4plsql.xml - see error log"
validMsg="-> VALID: Successfully updated log4plsql.xml"
export log4plsqlxml=${orcaHome}/Log4plsql/properties/log4plsql.xml
export grepXml=HOST_NAME
export lineNum=`grep -n ${grepXml} ${log4plsqlxml} | awk -F: '{print $1}'`
echo "#!/bin/ksh
ed -s ${log4plsqlxml} <<EOF >/dev/null
${lineNum}
d
${lineNum}-1
a
<dburl>jdbcSmilieracle:thin:@${DB_HOST}:1521:${ORACLE_SID} /dburl>
.
w
q
EOF" > /tmp/log4plsqlED && chmod 755 /tmp/log4plsqlED && /tmp/log4plsqlED
confirm_return
rm /tmp/log4plsqlED
}

What do u think about this kind of method?
Do you have any efficient alternatives to edit files?

Thanks in advance,
Nir
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script deleting my files, and editing files in subdirectories question

#!/bin/bash # name=$1 type=$2 number=1 for file in ./** do if then filenumber=00$number elif then filenumber=0$number fi tempname="$name""$filenumber"."$type" if (4 Replies)
Discussion started by: TheGreatGizmo
4 Replies

2. Homework & Coursework Questions

need help with shell programing script

1. The problem statement, all variables and given/known data: Write a Shell script to automatically check that a specified user is logged in to the computer. The program should allow the person running the script to specify the name of the user to be checked, the frequency in seconds at... (5 Replies)
Discussion started by: operator
5 Replies

3. Programming

Shell programing to implement SQL package

hi all, i have a table with employee details like his name,addr,DOB etc. i need a shell program which takes one date as input from user and print the employees whose DOB is less than that date. in sql package the select query is written (2 Replies)
Discussion started by: vidyaj
2 Replies

4. Shell Programming and Scripting

Editing files to add some thing in all the files in a folder

Hi All, I have a folder that contains 100's of files and each file have a similar content like the following format: ((STBJa:200.0,((STBTz:200.0,(STSwe:200.0,(STDUw:200.0,(ST4Bu:200.0,STL2b:200.0):127.0):86.0):80.0):120.0, STAHr:200.0):134.0):200.0,STuNg:200.0);What I need is to do is add "#1"... (2 Replies)
Discussion started by: Lucky Ali
2 Replies

5. Shell Programming and Scripting

Editing lists of integers in 1d files with bash shell

Hi, I need a script that will: 1. Go through about 20 different folders, each containing about 20 1d files. The 1d files go something like this: 22.253 37.707 78.117 112.374 127.944 156.067 180.956 233.785 249.256 ... (1 Reply)
Discussion started by: ac130pilot
1 Replies

6. Shell Programming and Scripting

Shell Programing with awk Tool

I'm working on a program in with shell programming and it needs to be able to delete the contents of files in the Home directory on certain days of the week.(like tuesday). Can anyone help me with this? Thanks in advance, Taffy. (7 Replies)
Discussion started by: Taffy
7 Replies

7. Shell Programming and Scripting

shell programing...

Hi... i need to write a shell script wich shows the full name and station of every logged user in the system. pls help! (1 Reply)
Discussion started by: relu89
1 Replies

8. Programming

A C++ programing Shell on Win

Hello I need to translade the power of unix command shell (grep, sed, awk, wc, etc..) to windows. In my work every day I administrate 15 unix server ans 18 windows server, and I have the problem the absolutly limitation of windows shell. I´m a system administrator but I know programming. I... (2 Replies)
Discussion started by: dalmus
2 Replies

9. Linux

Linux game programing or just shell scripting

Well Acording to my job... Anyhelp plz. I need some basic scripting stuff. (3 Replies)
Discussion started by: Irish Jimmy
3 Replies

10. Shell Programming and Scripting

mutex in shell programing

A shell in crontab per 5 min write a file B shell in crontab per 6 min read a file how to lock the share file a ;avioid confilict in write and read? Thx : -) (1 Reply)
Discussion started by: zz_xm
1 Replies
Login or Register to Ask a Question
SHAR(1) 						    BSD General Commands Manual 						   SHAR(1)

NAME
shar -- create a shell archive of files SYNOPSIS
shar file ... DESCRIPTION
The shar command writes a sh(1) shell script to the standard output which will recreate the file hierarchy specified by the command line op- erands. Directories will be recreated and must be specified before the files they contain (the find(1) utility does this correctly). The shar command is normally used for distributing files by ftp(1) or mail(1). EXAMPLES
To create a shell archive of the program ls(1) and mail it to Rick: cd ls shar `find . -print` | mail -s "ls source" rick To recreate the program directory: mkdir ls cd ls ... <delete header lines and examine mailed archive> ... sh archive SEE ALSO
compress(1), mail(1), tar(1), uuencode(1) HISTORY
The shar command appeared in 4.4BSD. BUGS
The shar command makes no provisions for special types of files or files containing magic characters. The shar command cannot handle files without a newline (' ') as the last character. It is easy to insert trojan horses into shar files. It is strongly recommended that all shell archive files be examined before running them through sh(1). Archives produced using this implementation of shar may be easily examined with the command: egrep -v '^[X#]' shar.file BSD
June 6, 1993 BSD