Linux / UNIX Tech Support Forum
This is a discussion on Script to open and read a file that is supplied as a command line arg within the Shell scripting forums, part of the Development/Scripting category; a script that will open and read a file that is supplied as a command line argument i have succeed ...
|
|||||||
| Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
a script that will open and read a file that is supplied as a command line
argument i have succeed to open the file but i am stuck Output the words in reverse order (sentence ) and Replace all instances of "his" with "her". Code:
strict;
warnings;
$_=@ARGV;
chomp $_;
#Open the File
while (<>)
{
print $_;
}
# Reverse Function
while (<IN>) {
print reverse OUT $_;
}
Last edited by nixcraft; 30-03-2009 at 05:23 PM. |
| Sponsored Links | ||
|
|
|
||||
|
Above is Perl script and not a shell script. Do you want Perl or Shell script?
__________________
Vivek Gite Linux Evangelist |
|
|||
|
i mangaed to this code so far
my $num = scalar(@reverse); for(my $i = 0; $i < $num; $i++) { if ($reverse[$i] eq 'his') { $reverse[$i] = 'her'; } elsif ($reverse[$i] eq 'His') { $reverse[$i] = 'Her'; } elsif ($reverse[$i] eq 'HIS') { $reverse[$i] = 'HER'; } } print "@reverse\n"; but still not working i dont know why |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shell script to count number of lines in file specified by the second command-line | seaman77 | Shell scripting | 1 | 16-03-2009 07:46 PM |
| Linux Command To Open RPM File | raj | Getting started tutorials | 0 | 10-09-2008 06:08 PM |
| Command that inserts two outputs in same line | eawedat | Shell scripting | 3 | 16-08-2008 08:48 AM |
| Read arguments from a file and pass them to binary file | AHJ | Shell scripting | 1 | 31-10-2007 06:04 PM |
| Command line remote access | angelus_kit | Networking, Firewalls and Security | 7 | 05-09-2007 06:30 PM |