[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: shell scripting....



Everything Robert said is great, but also check out 'sed' & 'awk'.
They can work wonders in the world of search and replace text
reformatting.

	- Kevin Colby
	  kevinc grainsystems com


robert_gasch peoplesoft com wrote:
> 
> > how do i do the following in some bash shell scripts i am writing...?
> 
> > 1) append text to the end of a file?
> 
> ls > outputfile          will re-create the file and send to output of ls
> to it
> ls >> outputfile         will open the file and *append* the output of ls
> 
> > 2) search a file for a certain name or text string and then remove it
> from
> > the file...?
> 
> Searching is easy:
> 
> grep pattern file        use grep -i for case insensitive searching
> 
> As for removing: a bit more subtle. If you know your string is unique, you
> can do
> 
> cat orig_file | grep -v pattern > new_file
> 
> grep -v will strip the pattern you specify, but it will strip the entire
> line ... for
> more contrived things (just a word on a line) use vi (or any other text
> editor)
> or you'd have to write some short awk/perl scripts ...
> 
> >  the system i am running is Redhat 6.0... and any help would be great.
> 
> All of this should work on any UNIX type system ...
> 
> Greetings
> --> Robert
> 
> --
>   PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
>                 http://www.redhat.com http://archive.redhat.com
>          To unsubscribe: mail redhat-install-list-request redhat com with
>                        "unsubscribe" as the Subject.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]