peter
asked on
sed script for large file
Hey everyone,
I have a rather large edit I need to make using sed. But the outcome is the file is doubled.
I need to take this paragraph....
java -jar -Dbase_dir=$BASE_DIR -Dlog_home=$LOG_HOME -Dserver.port=$SERVER_PORT -Dcom.sun.management.jmxre mote.port= $JMX_PORT -Dcom.sun.management.jmxre mote.ssl=f alse -Dcom.sun.management.jmxre mote.authe nticate=fa lse $BIN_DIR/xxxxx-boot-0.0.1- SNAPSHOT.j ar --spring.profiles.active=$ {ENV} --static.content.base=$BAS E_DIR/stat ic_29376 --server.context-path=/ --applicationURL=https://test.xxxxx.com --site_base=https://test.xxxxx.com/public --pySurveyConsoleUrl=https://test.xxxxx.com/adm/login/ &
and turn it into this
java -jar -Dbase_dir=$BASE_DIR -Dlog_home=$LOG_HOME -Dserver.port=$SERVER_PORT -Dcom.sun.management.jmxre mote.port= $JMX_PORT -Dcom.sun.management.jmxre mote.ssl=f alse -Dcom.sun.management.jmxre mote.authe nticate=fa lse $BIN_DIR/xxxxx-boot-0.0.1- SNAPSHOT.j ar --spring.profiles.active=$ {ENV} --static.content.base=$BAS E_DIR/stat ic_29376 --server.context-path=/ --applicationURL=https://ohiotest.xxxxx.com --site_base=https://ohiotest.xxxxx.com/public --pySurveyConsoleUrl=https://ohiotest.xxxxx.com/adm/login/ &
the only things that need to change is the references to ohiotest which replace test
When I try to accomplish that using this sed script, I get both paragraphs squished together. meaning, doubled up, and not one edited paragraph.
Heres the sed script I'm using.....
sudo sed -i 's#changethismess#tothatme ss#g' /home/somedirectory/somefi le
So the outpout looks like this....which is doubled up....
java -jar -Dbase_dir=$BASE_DIR -Dlog_home=$LOG_HOME -Dserver.port=$SERVER_PORT -Dcom.sun.management.jmxre mote.port= $JMX_PORT -Dcom.sun.management.jmxre mote.ssl=f alse -Dcom.sun.management.jmxre mote.authe nticate=fa lse $BIN_DIR/xxxxx-boot-0.0.1- SNAPSHOT.j ar --spring.profiles.active=$ {ENV} --static.content.base=$BAS E_DIR/stat ic_29376 --server.context-path=/ --applicationURL=https://test.xxxxx.com --site_base=https://test.xxxxx.com/public --pySurveyConsoleUrl=https://test.xxxxx.com/adm/login/ &java -jar -Dbase_dir=$BASE_DIR -Dlog_home=$LOG_HOME -Dserver.port=$SERVER_PORT -Dcom.sun.management.jmxre mote.port= $JMX_PORT -Dcom.sun.management.jmxre mote.ssl=f alse -Dcom.sun.management.jmxre mote.authe nticate=fa lse $BIN_DIR/xxxxx-boot-0.0.1- SNAPSHOT.j ar --spring.profiles.active=$ {ENV} --static.content.base=$BAS E_DIR/stat ic_29376 --server.context-path=/ --applicationURL=https://ohiotest.xxxxx.com --site_base=https://ohiotest.xxxxx.com/public --pySurveyConsoleUrl=https://ohiotest.xxxxx.com/adm/login/ &
I have a rather large edit I need to make using sed. But the outcome is the file is doubled.
I need to take this paragraph....
java -jar -Dbase_dir=$BASE_DIR -Dlog_home=$LOG_HOME -Dserver.port=$SERVER_PORT
and turn it into this
java -jar -Dbase_dir=$BASE_DIR -Dlog_home=$LOG_HOME -Dserver.port=$SERVER_PORT
the only things that need to change is the references to ohiotest which replace test
When I try to accomplish that using this sed script, I get both paragraphs squished together. meaning, doubled up, and not one edited paragraph.
Heres the sed script I'm using.....
sudo sed -i 's#changethismess#tothatme
So the outpout looks like this....which is doubled up....
java -jar -Dbase_dir=$BASE_DIR -Dlog_home=$LOG_HOME -Dserver.port=$SERVER_PORT
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm sorry to add, while the transformation works, the original file is unaltered.
look at using the -i option to indicate you want the change to occur to the file .
sed -i.bak -e "s/test/ohiotest/g" /home/user/dir/bin/start_w _jmx.sh
if replaced, the original file will be backed up
as /home/user/dir/bin/start_w _jmx.sh.ba k
sed -i.bak -e "s/test/ohiotest/g" /home/user/dir/bin/start_w
if replaced, the original file will be backed up
as /home/user/dir/bin/start_w
ASKER
that works, thanks!
ASKER
sed -e "s/test/ohiotest/g" /home/user/dir/bin/start_w