- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Scrpit help
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2004 07:40 AM
02-19-2004 07:40 AM
I am writing a script that does a replace within a series of text files. The problem that i am having is with the sed portion of it.
The line that I am replacing will always be line 4. It starts with "startprogram_gui: " followed by other text. I need to replace the other text with "otczsvmsg1"
The problem is that I could use a series of sed commands to do it, but I was hoping that there is a more elegant method.
Any quick ideas?
Good points for all
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2004 07:53 AM
02-19-2004 07:53 AM
Re: Scrpit help
sed 's/gui.*$/guisomething/' dummy >dummy2
Regards,
dl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2004 07:54 AM
02-19-2004 07:54 AM
Re: Scrpit help
try this simple script, using your input file as $1:
#!/usr/bin/sh
while read word rest
do
if [ "$word" = "startprogram_gui:" ]
then
rest="otczsvmsg1"
fi
echo "$word $rest"
done <$1
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2004 09:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2004 06:14 PM
02-19-2004 06:14 PM
Re: Scrpit help
will IN PLACE make the substitutions in all files passed
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2004 06:34 PM
02-19-2004 06:34 PM
Re: Scrpit help
sed '4s/^startprogram_gui:.*$/startprogram_gui: otczsvmsg1/'
(On line 4, replace the line if it starts with .... to ...)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2004 01:15 AM
02-20-2004 01:15 AM
Re: Scrpit help
# ========================================================================
# This script is used for global modifications of all profiles..
# This is was written to disseminate a test condition to lock accounts
# prior to backup/export
# Written by Rex Mueller - Unix Systems Engineer 6/2/2003
# FILE NAME /pei/peitools/bin/profchange
# ========================================================================
#
# ========================================================================
# DEFINE GLOBAL VARIABLES
# ========================================================================
export SDE=`date +%m%d%Y`
#echo $SDE
export STI=`date +%T`
#echo $STI
A=`cat /etc/passwd|wc -l`
export A
B=15
export B
C=`expr $A - $B`
export C
# ECHO VARIABLES FOR TESTING ONLY!!!
#echo $A
#echo $B
#echo $C
tail -n +15 /etc/passwd > /tmp/passwd.tmp
#tail -n +$B /etc/passwd |more
export prof1=/.profile
# =========================================================================
# PROGRAM EXECUTION
# =========================================================================
#find / -name .profile -print > /tmp/proflist
for prof in `awk -F":" '{print $6}' /tmp/passwd.tmp`
do
# =========================================================================
# DEFINE LOCAL VARIABLES
# =========================================================================
export PROF2=$prof
echo $PROF2 > /tmp/dirtemp
#awk -F":" '{print substr( $6, 7, 3)}' /etc/passwd
awk -F":" '{print substr($1, 7, 3)}' /tmp/dirtemp > /tmp/disttemp
export dist=`cat /tmp/disttemp`
#echo $PROF2
#echo $PROF2$prof1
#echo $dist
# =========================================================================
# PROFILE MODIFICATION PROCESS USING LOCAL VARIABLES
# =========================================================================
cp profchange.template prochange.tmp
perl -p -i -e s/LOCKDIR/$dist"LOCK"/g prochange.tmp
cat $PROF2$prof1 > $PROF2/.profile.$SDE
cat $PROF2$prof1 >> prochange.tmp
cat prochange.tmp >> $PROF2$prof1
done
# =========================================================================
# ESU#3 DATA AND NETWORK PASSWORD EXCEPTION LIST
# Reverses Profile changes for Administrative and Helpdesk users
# dsrath, slforslu, dwmilan, glfergus, phillips, rmueller
# =========================================================================
cp -p /home/esu/dsrath/.profile.$SDE /home/esu/dsrath/.profile
cp -p /home/esu/slforslu/.profile.$SDE /home/esu/slforslu/.profile
cp -p /home/esu/dwmilan/.profile.$SDE /home/esu/dwmilan/.profile
cp -p /home/esu/glfergus/.profile.$SDE /home/esu/glfergus/.profile
cp -p /home/esu/phillips/.profile.$SDE /home/esu/phillips/.profile
cp -p /home/esu/rmueller/.profile.$SDE /home/esu/rmueller/.profile
# =========================================================================
# PROGRAM DONE!!!
# =========================================================================
# profile.template
if [ -d "/tmp/LOCKDIR" ]
then
cat /etc/motd
echo "press any key to continue\n"
read
exit
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2004 01:18 AM
02-20-2004 01:18 AM