Computing.Net > Forums > Unix > open file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

open file

Reply to Message Icon

Name: carlos
Date: December 10, 2001 at 15:27:00 Pacific
Comment:

How can I in a Shell Script open a file, read and process an specific part of it ?

Thanks a lot!!



Sponsored Link
Ads by Google

Response Number 1
Name: ramzi
Date: December 10, 2001 at 20:16:49 Pacific
Reply:

To manually read and edit a file on the standard output:

#script begins
...
vi $file
# where file is the file name you want to
# work on
...
#script ends

To programmatically read and edit a file, e.g. to change harsh words into something else. In this example, lets consider "bad" is a harsh one and lets change any occurance of "bad" in the file (off course a text file) into "bxx":

# scripts begins
# this script expects a file name as an
# argument
...
if [ -f $1 ]
then
cat $1 | sed 's/ bad / bxx /g' > $1.new
fi
...
# scripts end

my humble suggestion does not necessarily meet your requirement.


0

Response Number 2
Name: carlos
Date: December 11, 2001 at 04:07:40 Pacific
Reply:

Thanks you!!!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: open file

UNIX open files www.computing.net/answers/unix/unix-open-files/4469.html

Skip open files with backup www.computing.net/answers/unix/skip-open-files-with-backup/3804.html

opening files from mounted unix volume www.computing.net/answers/unix/opening-files-from-mounted-unix-volume/1456.html