I have a text file with only the command:
MyTextFile:
ls -l
in it..
So in my sript im trying..
sh MyTextFile.txt >> MyTextFile.txt
Just to overwrite and replace the command with its output.
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..
i don't think you can read and write same file at the same time....
Yes! Sorry i was lazy...
I do have one more question.
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
it will simply compare for the file names not the file content..
if you wanna compare the content use
cmp -s file1 file2
if [ $? -eq 0 ] ; then
echo "files are same"
else
echo "files are not same"
fi