09-04-2010
Search & Replace question
Hi all,
I have one question that hopefully isn't too complicated for the more advanced users here. In one of the Solaris KSH scripts I'm working on, is it possible to script the following:
- If there "is" an empty blank line "at the end" of /tmp/text.txt, then remove only that one empty blank line from the end.
- If there is "no" empty blank line at the end of /tmp/text.txt, then append an "empty blank line" to the very end of that file.
I'm having difficulty with this one, but I suspect either awk or sed may be needed?
Thank you so much,
cg
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
I'm trying to do a global search and replace in vi. I am trying to replace a string, call it "BOB" with a carriage return and can't seem to find a reference to it.
Command syntax s%/BOB/???/g
What would I substitute the "???" with? (7 Replies)
Discussion started by: barnettdk
7 Replies
2. Shell Programming and Scripting
Plzzzz, tell me some script about this...
What does this mean ?
sed '/^ */s///'
sed '/^/s// /'
and why it's diferent ???
sed '/ */s// /g' and sed 's/ */ /g'. It's all the same ???
Thanks you very much (2 Replies)
Discussion started by: mle
2 Replies
3. Shell Programming and Scripting
Is there any way we can achieve search & replace with awk?
I could achieve the same with sed in following way -
sed 's/A/B/g' file1 > file2
But the same regex if I try with using awk following way,
awk 's/A/B/g' file1 > file2
it gives me Syntax error. I strongly believe I am... (1 Reply)
Discussion started by: videsh77
1 Replies
4. UNIX for Dummies Questions & Answers
Hey, I want to have a C program which, for an existing file supplied by the command line argument (E.g. File1.txt) replaces all the occurrences of the words:
"We” or “we” by “I”
“a” by “the”
“A” by “The”.
Then print the replaced file. All other characters of the file are to be left... (1 Reply)
Discussion started by: IwishIknewC
1 Replies
5. Shell Programming and Scripting
I have a file that has some accent characters in it when viewed in some text editors, but when viewed in vi they come in as ~R and ~U. I need to make a script to remove these characters from the file, but have been unsuccessful. I am not sure how sed or awk, or something similar is viewing them,... (8 Replies)
Discussion started by: tcovert
8 Replies
6. UNIX for Dummies Questions & Answers
Hi ,
I ahve a text file which has several instances of the text such as
run_time: 09:30
I need to add double quotes before and after the time value
i.e: run_time: "09:30"
Any suggestions on how to go about the same (4 Replies)
Discussion started by: jobbyjoseph
4 Replies
7. Shell Programming and Scripting
Hi I'm trying to replace a string in the files ending with *.txt
Unable to get the sed to do the job. any help would be appreciated :)
I'm on SunOS
#!/bin/bash
startdirectory={$HOME}/pp_test
searchterm="change"
replaceterm="CHANGE"
echo $searchterm
echo $replaceterm
for file in... (4 Replies)
Discussion started by: mqueue
4 Replies
8. Shell Programming and Scripting
Hi,
My problem is that I have to search a changing pattern and replace it with the wild card char "*"
i/p: 99_*_YYYYMMDD_SRC.txt.tar.gz
o/p: 99_*_*_SRC.txt.tar.gz
The problem is that YYYYMMDD pattern is not static. It could be YYYYMMDDHHMI or could be YYYYMMDDHHMISS.
Can... (10 Replies)
Discussion started by: dips_ag
10 Replies
9. Shell Programming and Scripting
Hi all
Please can you help me with a script to check several files for the following string:
encoding=""and replace it with:
encoding="UTF-8"I did the following, :
#!/bin/sh
string1="encoding="""
string2="encoding="UTF-8"
sed 's/'"$string1"'/'"$string2"'/g'but does not work.
Please can... (18 Replies)
Discussion started by: fretagi
18 Replies
10. Shell Programming and Scripting
Hi Gurus,
I have two files. I want to read sessoin_name from the file1 and replace $Param4 & $Param5 in file2 with connection_name in specified in file1.
The file1 will have data in following format
File 1
session_name,connection_name
s_abcd,Listener_2
s_def,Listener_1
source file... (7 Replies)
Discussion started by: r_t_1601
7 Replies
LEARN ABOUT SUSE
sieveshell
SIEVESHELL(1) User Contributed Perl Documentation SIEVESHELL(1)
NAME
sieveshell - remotely manipulate sieve scripts
SYNOPSIS
sieveshell [--user=user] [--authname=authname] [--realm=realm] [--exec=script] server[:port]
sieveshell --help
DESCRIPTION
sieveshell allows users to manipulate their scripts on a remote server. It works via MANAGESIEVE, a work in progress.
The following commands are recognized:
list list scripts on server.
put <filename> upload script to server.
get <name> [<filename>] get script. if no filename display to stdout
delete <name> delete script.
activate <name> activate script.
deactivate deactivate all scripts.
OPTIONS
-u user, --user=user
The authorization name to request; by default, derived from the authentication credentials.
-a authname, --authname=authname
The user to use for authentication (defaults to current user).
-r realm, --realm=realm
The realm to attempt authentication in.
-e script, --exec=script
Instead of working interactively, run commands from script, and exit when done.
REFERENCES
[MANAGESIEVE] Martin, T.; "A Protocol for Remotely Managing Sieve Scripts", draft-ietf-managesieve-03.txt, Mirapoint, Inc.; May 2001, work
in progress.
AUTHOR
Tim Martin <tmartin@mirapoint.com>, and the rest of the Cyrus team <cyrus-bugs@andrew.cmu.edu>.
perl v5.10.0 2008-04-04 SIEVESHELL(1)