12-06-2012
Quote:
Originally Posted by
Drenhead
How can I edit this file then? Can I output the changes to a different filename? I just need to edit the dates, but can't figure it out.
You can use the -i option I already mentioned, with the caveats I already mentioned that 1) it will create a temp file, 2) it doesn't truly work "in place" since that's not really possible for many kinds of text replacement operations.
Rule of thumb is, never edit your originals, if you make a mistake you've wrecked it.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a loop in a script that is given me an error but, when I do it on the command line it works perfectly. The sed statement has to use the variables from a file so the file is partitioned correctly. I am running on HP:
<Begin error>:
+ cat /u01/bteam/CNAM/1121/.partition
+ read line
+ +... (3 Replies)
Discussion started by: bthomas
3 Replies
2. UNIX for Dummies Questions & Answers
Can anyone tell me ...on the below listed command
cat /mnt/winbox/list_measurement/ds1c/ds1_f.rome_27A03A 2>> error_log | sed -e '1,3d;s/^/27A03A,/' | sed -e "s#\(.*\)#\1 ,$(date +%Y-%m-%d)#g" > /SBS/ds1_f.rome_27A03A
The outcome is this:
,2005-08-29 Forestdale,3:02 am MON AUG 29,... (9 Replies)
Discussion started by: Redg
9 Replies
3. Shell Programming and Scripting
Execution of the following segment is giving the error -
Script extract:-
OUT=$DATADIR/sol_rsult_orphn.bcp
TMP1=${OUT}_tmp1
TMP=${OUT}_tmp
( isql -w 400 $dbConnect_OPR <<EOF
select convert(char(10), s.lead_id)
+'|'
+ s.pho_loc_type,
";",
s.sol_rsult_cmnt,
";",
+'|'+ s.del_ind... (3 Replies)
Discussion started by: kzmatam
3 Replies
4. Shell Programming and Scripting
Can someone help me "port" this to AIX sed?
sed '/nas/{n;s/true/false/}'
I know it doesn't like the ; but i don't know how else to do it.... never had to sed on an AIX box :D (7 Replies)
Discussion started by: DeviousPete
7 Replies
5. Shell Programming and Scripting
Hi All
I'm getting this error while executing a sed script
sed: 0602-404 Function /</ i\ File from New Cube: cannot be parsed.
sed "/</ i\ File from New Cube:
/>/ i\ File from Old Cube:" difference1.txt > Difference.txt
I've a file like this
< Y2008 Dec ..... .... ... 345
I want... (6 Replies)
Discussion started by: Celvin VK
6 Replies
6. Shell Programming and Scripting
Hello ,
I am trying to replace a word :: complete to Failed .
work: complete
Sed command which i am using is given below ::
sed s/work: complete/Failed/g temp1.txt > temp2.txt (Sed command is grabled if i use the above .. because of space which is there between work: and complete. I... (6 Replies)
Discussion started by: raghav1982
6 Replies
7. Shell Programming and Scripting
Hi,
I am trying to use 3 sed statements in a shell script, but it get foll error.
sed : garbage after command.
If I use only two sed statements, the script works well.
Is there any restriction for sed usage or is there some catch which I am missing.
Sample Script is as follows :
... (3 Replies)
Discussion started by: sameersalve
3 Replies
8. Shell Programming and Scripting
hi
i have following sed command
this replaces "** in filename1 with octal value 007 filename2
when i put it in script it wont work but it works from command line
my OS is sun OS
---------- Post updated at 06:38 PM ---------- Previous update was at 06:14 PM ----------
i... (10 Replies)
Discussion started by: er_zeeshan05
10 Replies
9. Shell Programming and Scripting
Hi guys. Can somone advise as to what the problem is with the following sed command?
1) read -p "Please enter new username you wish to replace old: " new_username
sed "s/$username/$new_username/" information_file
;;
This is one of the case statements included but I'm... (1 Reply)
Discussion started by: jjb1989
1 Replies
10. Shell Programming and Scripting
I can't get this code to work, could I get some help...
sed -i '' "s:${shLogpath1}${cell}:${shLogpath2}${cell}:g" test.txt
Any Ideas, I think I need to separate the variables some how? (2 Replies)
Discussion started by: digitalviking
2 Replies
LEARN ABOUT DEBIAN
shtool-subst
SHTOOL-SUBST.TMP(1) GNU Portable Shell Tool SHTOOL-SUBST.TMP(1)
NAME
shtool-subst - GNU shtool sed(1) substitution operations
SYNOPSIS
shtool subst [-v|--verbose] [-t|--trace] [-n|--nop] [-w|--warning] [-q|--quiet] [-s|--stealth] [-i|--interactive] [-b|--backup ext]
[-e|--exec cmd] [-f|--file cmd-file] [file] [file ...]
DESCRIPTION
This command applies one or more sed(1) substitution operations to stdin or any number of files.
OPTIONS
The following command line options are available.
-v, --verbose
Display some processing information.
-t, --trace
Enable the output of the essential shell commands which are executed.
-n, --nop
No operation mode. Actual execution of the essential shell commands which would be executed is suppressed.
-w, --warning
Show warning on substitution operation resulting in no content change on every file. The default is to show a warning on substitution
operations resulted in no content change on all files.
-q, --quiet
Suppress warning on substitution operation resulting in no content change.
-s, --stealth
Stealth operation. Preserve timestamp on file.
-i, --interactive
Enter interactive mode where the user has to approve each operation.
-b, --backup ext
Preserve backup of original file using file name extension ext. Default is to overwrite the original file.
-e, --exec cmd
Specify sed(1) command directly.
-f, --file cmd-file
Read sed(1) command from file.
EXAMPLE
# shell script
shtool subst -i -e 's;(c) ([0-9]*)-2000;(c) 1-2001;' *.[ch]
# RPM spec-file
%install
shtool subst -v -n
-e 's;^(prefix=).*;1 $RPM_BUILD_ROOT%{_prefix};g'
-e 's;^(sysconfdir=).*;1 $RPM_BUILD_ROOT%{_prefix}/etc;g'
`find . -name Makefile -print`
make install
HISTORY
The GNU shtool subst command was originally written by Ralf S. Engelschall <rse@engelschall.com> in 2001 for GNU shtool. It was prompted
by the need to have a uniform and convenient patching frontend to sed(1) operations in the OpenPKG package specifications.
SEE ALSO
shtool(1), sed(1).
18-Jul-2008 shtool 2.0.8 SHTOOL-SUBST.TMP(1)