bash script working for small size files but not for big size files.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting bash script working for small size files but not for big size files.
# 1  
Old 11-01-2006
bash script working for small size files but not for big size files.

Hi,

I have one file stat.

Stat file contents are as follows: for example.
Code:
H50768020040913,00260100,507680,13,0000000643,0000000643,00000,0000 
H50769520040808,00260100,507695,13,0000000000,0000000000,00000,0000 H50770620040611,00260100,507706,13,0000000000,0000000000,00000,0000

Now i have to get the date from that stat file and based on the date i have to do some deletion on the data.

Shell Script has been written for this, and it works fine. The script is attached below.

Code:
a =`cat $1`
IFS=' '
set `date`
m=$2
case $m in
jan*|Jan*) m=1 ;;
feb*|Feb*) m=2 ;;
mar*|Mar*) m=3 ;;
apr*|Apr*) m=4 ;;
may*|May*) m=5 ;;
jun*|Jun*) m=6 ;;
jul*|Jul*) m=7 ;;
aug*|Aug*) m=8 ;;
sep*|Sep*) m=9 ;;
oct*|Oct*) m=10 ;;
nov*|Nov*) m=11 ;;
dec*|Dec*) m=12 ;;
esac
v=$6$m
if test $m = 12
then
m=`expr $m - 2`
else
m=`expr $m - 2`
m=0$m
fi
s=01
v=$6$m$s
echo hai
set $a
IFS=' '
for i in $*
do
q=$i
IFS=','
set $i
set recval = `echo $1 | awk '{print substr($0,8,8)}'`
w=$3
if test $w -gt $v
then
echo $q >>cc.txt
fi
done

This is working fine for small size files (stat file).
If i run this script for big size files, then i get error as 'argument expected'

Please help me on this.

Thanks
David
# 2  
Old 11-01-2006
code tags for code please. It makes code readable. Like {code} stuff {/code} except with [ ] instead of { }.

I take it $1 is the stat file? What is the a=`cat $1` bit for? $a isn't even used anywhere else.

If $a is used anywhere else, this'd be the weak point. Shell variables have size limits. Use pipes instead.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Help with Expect script for pulling log files size larger than 500Mb;

I am new at developing EXPECT scripts. I'm trying to create a script that will automatically connect to a several UNIX (sun solaris and HPUX) database server via FTP and pull the sizes of the listener/alert log files from specified server directory on the remote machines. 1. I want the script... (7 Replies)
Discussion started by: mikebantor
7 Replies

2. Red Hat

Du -sh command taking time to calculate the big size files

Hi , My linux server is taking more time to calculate big size from long time. * i am accessing server through ssh * commands # - du -sh * #du -sh * | sort -n | grep G Please guide me for fast way to find big size directories under to / partition Thanks (8 Replies)
Discussion started by: Nats
8 Replies

3. Shell Programming and Scripting

Help in Shell script to report size of files=0

Hello, I am trying to write a shell script in unix which looks for the last two files in a folder, checks their size and reports(via mail) if either of their file size is =0. cd /tmp list last two files: ls -ltr | tail -2 check if size of any of these two files is 0 if true, then send a... (8 Replies)
Discussion started by: kiran1112
8 Replies

4. Emergency UNIX and Linux Support

Script to fill the file system mount with empty files to desired size

We are regularly using for our testing, where we are manually filling up the mount with desired size with following command dd if=/dev/zero of=file_2GB bs=2048000 count=2000 We are planning to automate the task where taking input for % of size as one input and the name of the file system... (8 Replies)
Discussion started by: chandu123
8 Replies

5. Shell Programming and Scripting

How to delete some of the files in the directory, if the directory size limits the specified size

To find the whole size of a particular directory i use "du -sk /dirname".. but after finding the direcory's size how do i make conditions like if the size of the dir is more than 1 GB i hav to delete some of the files inside the dir (0 Replies)
Discussion started by: shaal89
0 Replies

6. Shell Programming and Scripting

Shell script to calculate the size of files

Dear all, Please help me to write a script that can calculate the size of files. For example: I have a directory which contain thousands of files. I need to know the size of files that their name begin with abc_123 Thank all!! (4 Replies)
Discussion started by: hainguyen1402
4 Replies

7. Shell Programming and Scripting

Comparing same size of files using KSH script

Hi, I have a requirement I have to find out the same size of files with different name in a particular directory. For ex: I have around 1 lack records in a directory and in that I have abcd.jpg, abcd_1.jpg with same size each. I need to seperate these two records from that file.... (3 Replies)
Discussion started by: siri_886
3 Replies

8. Shell Programming and Scripting

Merge files of differrent size with one field common in both files using awk

hi, i am facing a problem in merging two files using awk, the problem is as stated below, file1: A|B|C|D|E|F|G|H|I|1 M|N|O|P|Q|R|S|T|U|2 AA|BB|CC|DD|EE|FF|GG|HH|II|1 .... .... .... file2 : 1|Mn|op|qr (2 Replies)
Discussion started by: shashi1982
2 Replies

9. Shell Programming and Scripting

This script cut size of files "Lol" change string in files

Basic: find . -type f -name “*.txt” -print | awk '{gsub("Ontem", "AntesdeOntem", $0); print > FILENAME}' *.txt The idea is in folder /home/myapontamentos I have some files and i need to change in all them the word "ontem" to "antesdeontem". But bigger files are cut (size i mean)... (4 Replies)
Discussion started by: single
4 Replies

10. UNIX for Dummies Questions & Answers

shell script to find files by date and size

Hi, I have a directory PRIVATE in which I have several directories and each of these have several files. Therefore, I need to find those files by size and date to back up those files in another directory. I don't know how to implement this shell script using ''find''. appreciate any... (1 Reply)
Discussion started by: dadadc
1 Replies
Login or Register to Ask a Question