The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how can i run perl oneliner to excute every N seconds? umen Shell Programming and Scripting 1 08-18-2008 12:25 PM
Executing file without excute permission. ashish_uiit UNIX for Dummies Questions & Answers 4 05-08-2008 06:34 PM
is there any way to excute script every N seconds? umen Shell Programming and Scripting 7 03-30-2006 04:06 AM
Reading file names from a file and executing the relative file from shell script anushilrai Shell Programming and Scripting 4 03-10-2006 05:25 AM
help! can't excute hassan2 UNIX for Advanced & Expert Users 6 09-10-2002 02:30 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-09-2008
omgsomuchppl omgsomuchppl is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 17
Excute file then..

I have a text file with only the command:

MyTextFile:
Code:
ls -l
in it..

So in my sript im trying..
Code:
sh MyTextFile.txt >> MyTextFile.txt
Just to overwrite and replace the command with its output.
Code:
 
sh MyTextFile.txt 2>1 MyTextFile.txt
isnt redirecting either..
Im getting the output when i execute my script..
I want to see the output only when i cat the file..
  #2 (permalink)  
Old 12-09-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,390
i don't think you can read and write same file at the same time....
  #3 (permalink)  
Old 12-09-2008
omgsomuchppl omgsomuchppl is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 17
Yes! Sorry i was lazy...

I do have one more question.
Code:
if [ outputfile.txt == outputfile2.txt ]; then
echo "same"
else
echo "different"
Does that check for the contents of the text file and then match it? Or the bytes? Whats happenign when i try and compare two files in an if condition?

I just would like some difference to echo a true statement
  #4 (permalink)  
Old 12-09-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,390
it will simply compare for the file names not the file content..
if you wanna compare the content use
Code:
cmp -s file1 file2
if [ $? -eq 0 ] ; then
echo "files are same"
else
echo "files are not same"
fi
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On




All times are GMT -4. The time now is 11:39 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0