Convert bash to sh URGENT :(


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Convert bash to sh URGENT :(
# 1  
Old 04-18-2004
Convert bash to sh URGENT :(

Hi,

I have to write a program to compare 2 files for copying.

the program is ran on Solaris 5.8 like this:
script.sh file1.txt file2.txt

I wrote the program using bash and it took me forever since I am a beginner but it works very well.

I'm getting so close to the deadline and I realised today that actually I have to use normal Bourne shell (bin/sh) and not bash(bin/bash).

Could anyone PLEASE help me to adjust my script (like replacing arrays..) I'm just getting so desperate....

I just attach a file with the script and also 2 little text files to run the script.

PLEASE HELP me anyone! Thank you so much!


Chris.
# 2  
Old 04-18-2004
I think you will have less work changing your logic than adapting your script to sh.
Try something like this :
Code:
File1=$1
File2=$2

Work=/tmp/`basename $0`.$$
Work1=$Work.1
Work2=$Work.2

tr -d '[:blank:]' < $File1 | sort -o $Work1
tr -d '[:blank:]' < $File2 | sort -o $Work2

LINES_MATCHING=`comm -1 -2 $Work1 $Work2 | wc -l | awk '{print $1}'`
LINES_TOTAL=`wc -l $Work1 | awk '{print $1}'`
LINES_NOT_MATCHING=`expr $LINES_TOTAL - $LINES_MATCHING`
PERCENT_NOT_MATCHING=`expr $LINES_NOT_MATCHING \* 100 / $LINES_TOTAL`

rm -f $Work1 $Work2

echo "Matched: $LINES_MATCHING"
echo "Not Matched: $LINES_NOT_MATCHING  ($PERCENT_NOT_MATCHING%)"
echo "Total: $LINES_TOTAL"

# 3  
Old 04-18-2004
That's what I thought, I just have to change it all....... Smilie short night ahead....!



Chris
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash to convert to m-d-yyyy

I am using bash that when run downloads a file a verifies that there is data in it. What I am not able to do is have a user enter a date in any format they wish and have it converted to m-d-yyyy. Thank you :). Bash printf " Welcome to NGS analysis, checking for new files and creating a... (2 Replies)
Discussion started by: cmccabe
2 Replies

2. Ubuntu

Convert a bash to ash

hello everybody, i'm a beginner in ash and i want to convert this bash script to ash. this script send a xml file to a nagios server : #!/bin/bash PROGNAME=$(basename $0) RELEASE="Revision 0.3" print_release() { echo "$RELEASE" } print_usage() { echo "" echo "$PROGNAME... (6 Replies)
Discussion started by: mdijoux25
6 Replies

3. Programming

Urgent help needed.. C++ program to convert decimal to hexa decimal

Hi , seq can be 0...128 int windex = seq / 8; int bindex = seq % 8; unsigned char bitvalue = '\x01' << (7-bindex) ; bpv.bitmapvalue = bitvalue; This is the part of a program to convert decimal to bitmap value of hexadecimal. I want this to change to convert only to... (1 Reply)
Discussion started by: greenworld123
1 Replies

4. Programming

Convert Bash script to C

dear all, i need your advice for convert bash shell to C programming INDEX=/zpool1/NFS/INDEX/${1} SCRIPT=/zpool1/NFS/script/${1} LIST=SAMPLE cd ${SCRIPT} for i in `cat ${LIST}` do GETDATE=`echo ${i}|awk '{print substr($1,9,8)}'` /usr/xpg4/bin/awk -F ":" '{close(f);f=$4}{print >>... (2 Replies)
Discussion started by: zvtral
2 Replies

5. UNIX for Dummies Questions & Answers

urgent help to convert xml to xsl or csv

Urgent help to transfer data from .xml to xl sheet where each attribute and value goes into seperate column.Please help me with the command.Please help Thanks Uma (9 Replies)
Discussion started by: umapearl
9 Replies

6. Shell Programming and Scripting

Program Bash VERY URGENT

Hello I have to do a program in Bash, need help because it does not go out for me and go enough time with this!! Five directories(boards of directors) that more occupy, arranged according to size. To measure the size of every directory(board of directors) there must not be included the size... (1 Reply)
Discussion started by: danihj
1 Replies

7. UNIX for Advanced & Expert Users

Urgent! need help! how to convert this file into comma delimited format

Hi experts, I need urget help! I have the a text file with this format: Types of fruits Name of fruits 1,1 Farm_no,1 apple,1 pineapple,1 grapes,1 orange,1 banana,1 2,2--->this is the record seperator Farm_no,2 apple,1 pineapple,1 grapes,3 orange,2 banana,1 3,3--->this is the... (2 Replies)
Discussion started by: natalie23
2 Replies

8. Shell Programming and Scripting

***convert from perl to bash***

can any body translate the follwing script into one that works in bash? #!/usr/bin/perl # classify_books.pl my $csv_file = shift; my %categories = ( 'childrens' => 'childrens_books.txt', 'horror' => 'horror_books.txt', 'sports ' =>... (3 Replies)
Discussion started by: ferrycorsten73
3 Replies

9. Shell Programming and Scripting

how to convert the result of the select query to comma seperated data - urgent pls

how to convert the result of the select query to comma seperated data and put in a .csv file using korn shell. Pls help me as its very urgent. Thanks, Hema. (1 Reply)
Discussion started by: Hemamalini
1 Replies

10. Shell Programming and Scripting

Urgent!! Bash - problem using CD with variable

I am extracting directory path from file which is stored in a variable. while read inputline do script_name=`echo $inputline | cut -d' ' -f2` cd $script_name done < path_scripts.txt where as path_scripts contains input_process.bash ~/jobs/process/input/bin The script output says... (1 Reply)
Discussion started by: jacksam007
1 Replies
Login or Register to Ask a Question