Hello
I suppose the following command will change every 'oslib' to
'stdio' in file a.
But it doesn't work. Because it change every 'oslib' to 'stdio' and
place it into a new file '{}'
would you like to tell me how to fix it?
thanks
But it doesn't work. Because it change every 'oslib' to 'stdio' and
place it into a new file '{}'
would you like to tell me how to fix it?
thanks
>would you like to tell me how to fix it?
>thanks
> But it doesn't work. Because it change every 'oslib' to 'stdio' and
> place it into a new file '{}'
> would you like to tell me how to fix it?
> thanks
$ sed -e 's/oslib/stdio/g' a
where a is the file you wish to execute the substitution.
Regards!
David
> I don't know which command you have typed but the _following_ does the
> trick (writes to the standard output):
> $ sed -e 's/oslib/stdio/g' a
> where a is the file you wish to execute the substitution.
shell> cat a | sed 's/oslib/stdio/g' > b
Which saves the corrected file to file "b"
--
Jon Langseth
> > But it doesn't work. Because it change every 'oslib' to 'stdio' and
> > place it into a new file '{}'
> What doesn't work? Care to give us few hints, or should we take wild
> guesses and give you random answers?
> > would you like to tell me how to fix it?
> > thanks
find file_a -exec sed s/oslib/stdio/ {} > {}
It should change every oslib to stdio in file_a and save it to file_a.
But it saved to file {}. It seen "find" doesn't convert the second {}
to the file name it found
This command doesn't work
thanks
> find file_a -exec sed s/oslib/stdio/ {} > {}
> It should change every oslib to stdio in file_a and save it to file_a.
> But it saved to file {}. It seen "find" doesn't convert the second {}
> to the file name it found
> This command doesn't work
find <starting_directory> -name file_a
-exec sed 's/oslib/stdio/' {} > {}.new \;
(above command typed all on one line)
This will edit all files named "file_a" but giving the resulting
edited file the name file_a.new. ("sed" does not do an "inplace"
edit.) The terminating "\;" for the "-exec" element is required.
The Gnu version of find does allow the <starting directory> to
be omitted, in which case the current directory is used as the
starting point for the search.
--
Dave Brown Austin, TX
>> find file_a -exec sed s/oslib/stdio/ {} > {}
> find <starting_directory> -name file_a
> -exec sed 's/oslib/stdio/' {} > {}.new \;
And, if you have to search for files to process, then do
find . -type f -name '...' | while read a; do
sed 's/oslib/stdio/g' $a > tmp && mv tmp $a
done
--
8-CPU Cluster, Hosting, NAS, Linux, LaTeX, python, vim, mutt, tin
> {} should be escaped like \{\} or '{}', otherwise shell complains. But,
> ...
--
Dave Brown Austin, TX
> > find file_a -exec sed s/oslib/stdio/ {} > {}
> > It should change every oslib to stdio in file_a and save it to file_a.
> > But it saved to file {}. It seen "find" doesn't convert the second {}
> > to the file name it found
> > This command doesn't work
> Commands only work if they are used with the proper syntax. Apparently
> you haven't looked at the manpage, nor looked through the books in
> your Unix library for examples of using the "find" command. Trial and
> error will take you forever, and this is just for one command.
> find <starting_directory> -name file_a
> -exec sed 's/oslib/stdio/' {} > {}.new \;
> (above command typed all on one line)
> This will edit all files named "file_a" but giving the resulting
> edited file the name file_a.new. ("sed" does not do an "inplace"
> edit.) The terminating "\;" for the "-exec" element is required.
> The Gnu version of find does allow the <starting directory> to
> be omitted, in which case the current directory is used as the
> starting point for the search.
>> find <starting_directory> -name file_a
>> -exec sed 's/oslib/stdio/' {} > {}.new \;
>> (above command typed all on one line)
> Sorry, doesn't work. It will not saved to file_a.new. It saved to {}.new
> thank anyway
So lets use a command that does inplace editing:
find . -name file_a -exec perl -pi -e 's/oslib/stdio/' {} \;
Seems a shame to have exec perl each time. If it were something
other than a one-shot deal, it would probably better be done by finding
all the files first, putting their pathnames in a file, then writing
a perl script to do the processing in a single execution.
--
Dave Brown Austin, TX
> >> find <starting_directory> -name file_a
> >> -exec sed 's/oslib/stdio/' {} > {}.new \;
> >> (above command typed all on one line)
> > Sorry, doesn't work. It will not saved to file_a.new. It saved to {}.new
> > thank anyway
Quote:> Aha! The exec statement can't do redirection! (Quoting the exec
> statement didn't seem to help.)
> So lets use a command that does inplace editing:
> find . -name file_a -exec perl -pi -e 's/oslib/stdio/' {} \;
> Seems a shame to have exec perl each time. If it were something
> other than a one-shot deal, it would probably better be done by finding
> all the files first, putting their pathnames in a file, then writing
> a perl script to do the processing in a single execution.
1. Need to find vi command to remove ^H from command man find > find.txt
hi there,
Q1: i need to find out the vi command needed to change all occurences of
some character followed by a backspace to nothing. that is to remove the ^H
sequence created by the following command man find > find.txt .
Q2:can sed perform the same task as vi?
Q3:what would be the command also for sed ?
thanks.
Iskandar
2. Format of pre-formatted tape for Wangtek 3080T
3. need to pipe a find or locate command into the rm command....PLEASE help!
5. CLUB: Linux User Group of Davis, Feb. 21st, "GDB - The GNU Debugger"
6. Piping results of a 'find' command to a 'mv' command...
7. LMS/Phillips CM-205 CDROM Support
8. Linux Commands- Where can i find list of Linux Commands for the console?
9. Need to find info on the 'FIND' command
10. find command to find files of a certain date
11. "find" command to find file on specific date?