need help in writing a comparison shell script

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need help in writing a comparison shell script
# 1  
Old 08-12-2009
need help in writing a comparison shell script

I have a folder a1 with the following files


In another folder there is a file b with the value 5

My script should take the value 5 ( file b), compare it with the files in folder a1, if file name contains the number less than 5, the files in a1 should be deleted.

output should be - sample_1, sample_2, sample_3, sample_4 files deleted.

Kindly help.......
# 2  
Old 08-13-2009
# Generic for all posix shells

read value < valuefile
for f in sample_*.log
     # remove sample_ and .log
     (( id >= value )) && continue
     echo "rm -f $f"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Date and Time comparison using shell script

Hi, I'm having two fields in the file F1|F2 20111220|102000 F1 ->YYYYMMDD F2 ->HHMMSS Now, I need to compare this with current date & time and need to return the difference value in hours. Already, I checked with datecalc from the forum. So, need hints from Shell Gurus. Thanks (10 Replies)
Discussion started by: buzzusa
10 Replies

2. Shell Programming and Scripting

Korn shell script comparison

I have a scenario to implement in Korn shell script. Here it is.. I need to compare two values to see whether they are same or not. The issue is that the values coming in for comparison can be a string or an integer which can be determined during run time only. Which korn shell comparison... (1 Reply)
Discussion started by: vani123
1 Replies

3. Shell Programming and Scripting

File comparison in shell script

Hi, I have written one script : #!/bin/bash echo -n -e "\nEnter how many files : " read no for (( j=1; j<=$no; j++ )) do echo -n -e "\nEnter $j File name : " read name done for (( j=1; j<=$no; j++ )) do FILE=`find ./ -type f -name "${name}"` echo "$FILE" (3 Replies)
Discussion started by: kiran_j
3 Replies

4. Solaris

String Comparison in Shell script

I Have a script which gets the status of oracle database and if the status is READ WRITE should echo "db is up " else "db is down" Here is the code if then echo "db up" else echo "db down" fi done; The script is giving me out put "db down" even thoug the value of... (6 Replies)
Discussion started by: njafri
6 Replies

5. Shell Programming and Scripting

How to do row comparison in shell script

Hi, I need help on doing the below thing in shell script. I have a file with millions of rows called "abc.txt". i have another file with millions of rows called "xyz.txt". I would like to do the below operation. Open the abc.txt, read the first line, do some operations on the column... (2 Replies)
Discussion started by: informsrini
2 Replies

6. Shell Programming and Scripting

bash shell script string comparison

I want to remove a line that has empty string at second field when I use cut with delimeter , like below $cat demo hello, mum hello, #!/bin/sh while read line do if then # remove the current line command goes here fi done < "demo" i got an error message for above... (4 Replies)
Discussion started by: bonosungho
4 Replies

7. AIX

Difference between writing Unix Shell script and AIX Shell Scripts

Hi, Please give me the detailed Differences between writing Unix Shell script and AIX Shell Scripts. Thanks in advance..... (0 Replies)
Discussion started by: haroonec
0 Replies

8. Shell Programming and Scripting

Need help for writing shell script

Hello ALL, I am fresher in Unix . i need help to write small shell script . Please help me unix guru. I am developing the internal site in my office . the data files are generated in one directory everyday . I have to write shell script to sort those files and put it is internal site . ... (3 Replies)
Discussion started by: deepa20
3 Replies

9. Shell Programming and Scripting

Help with time comparison shell script for HP-UX

I am using Korne Shell in HP-Ux. Can someone give me and idea on how I can write a shellscript on how to do this please:- On our HP-UX server, a batch file is run every evening at about 6:30pm. The first step of this batch file will touch an empty "flag" file to indicate that the batch has... (6 Replies)
Discussion started by: gummysweets
6 Replies

10. Shell Programming and Scripting

Need help with writing shell script

I have the following output. I want to write a script to check for 1. waits > 0 on all rowsand Ratio > .0. if true then send email. ========================= ROLLBACK SEGMENT CONTENTION ========================= If any ratio is > .01 then more rollback segments are needed NAME ... (1 Reply)
Discussion started by: jigarlakhani
1 Replies
Login or Register to Ask a Question