nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

Script to open and read a file that is supplied as a command line arg

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 ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 30-03-2009, 03:17 PM
Junior Member
User
 
Join Date: Mar 2009
OS: Debian
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
blingbling is on a distinguished road
Default Script to open and read a file that is supplied as a command line arg

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.
Reply With Quote
  #2 (permalink)  
Old 30-03-2009, 05:23 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 244 Times in 183 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Above is Perl script and not a shell script. Do you want Perl or Shell script?
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #3 (permalink)  
Old 30-03-2009, 07:29 PM
Junior Member
User
 
Join Date: Mar 2009
OS: Debian
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
blingbling is on a distinguished road
Default

perl please
Reply With Quote
  #4 (permalink)  
Old 31-03-2009, 10:54 AM
Junior Member
User
 
Join Date: Mar 2009
OS: Debian
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
blingbling is on a distinguished road
Default

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
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

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


All times are GMT +5.5. The time now is 11:47 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38