I am using shell script. How to copy one file content to another file using "sed". I have to use only sed to complete this copy. can anyone help me?
Thanks in advance Sudha
I am using shell script. How to copy one file content to another file using "sed". I have to use only sed to complete this copy. can anyone help me?
Thanks in advance Sudha
sed writes its output on standard output, not in a file. You have to use redirections. One possible command is:
sed -n 'p' myInFile > myOutFile
All you need is a noop:
sed -e '' <"${OLDNAME}" >"${NEWNAME}"
...that said, why? Most tiny embedded systems will be using busybox, and while they may not have cp (hey, I've built a busybox without one for a dedicated router appliance!), not adding cat to the busybox config is just silly.
As suggested, you can do this with sed, but why not simply copy the file with the cp command?
If you actually wanted to use the write functionality in sed, you could use the w
command to write to a specific file
sed -n "w$NEWNAME" $OLDNAME