Computing.Net > Forums > Unix > Editing a file without awk or sed

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.

Editing a file without awk or sed

Reply to Message Icon

Name: Ron
Date: August 8, 2003 at 04:36:33 Pacific
OS: XP
CPU/Ram: AMD
Comment:

Hi. I need to write a script to edit a file without using awk or sed. I am given
J5: J4
J2: J3
J1: J2 J3
J: J2 J3 J4

And the output should become

J5.class: J4.class
J2.class: J3.class
J1.class: J2.class J3.class
J.class: J2.class J3.class J4.class

That is .class has to be appended.
Please help




Sponsored Link
Ads by Google

Response Number 1
Name: ArnoldF
Date: August 8, 2003 at 07:08:29 Pacific
Reply:

homework?



0

Response Number 2
Name: Jake
Date: August 8, 2003 at 08:36:34 Pacific
Reply:

Is PERL legal?

#!/usr/bin/perl
while( $line = <> )
{
$temp = $line;
while( $temp =~ m/(J[12345]?)(:?)/ )
{
print "$1.class$2 ";
$temp =~ s/$1//;
}
print "\n";
}


0

Response Number 3
Name: WilliamRobertson
Date: August 8, 2003 at 10:20:45 Pacific
Reply:

Or vi/ex/ed with a macro script, e.g:

vi myfile.dat < myscript.vi

Put the vi commands in myscript.vi, including the ':'. Remember to end with ':wq'.

Or use ex in place of vi - slightly leaner & meaner. Same thing but leave out the colons.


0

Response Number 4
Name: Dlonra
Date: August 9, 2003 at 08:08:19 Pacific
Reply:

i would bet the instructor wants it done with "pure" shell - no awk,sed,perl,ex or vi.



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: Editing a file without awk or sed

Increment a number using awk or sed www.computing.net/answers/unix/increment-a-number-using-awk-or-sed/6827.html

Compare two files using awk or sed, add value www.computing.net/answers/unix/compare-two-files-using-awk-or-sed-add-value/8499.html

sed on a file www.computing.net/answers/unix/sed-on-a-file/4866.html