Unix commands failing inside the shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unix commands failing inside the shell script
# 1  
Old 06-02-2009
Unix commands failing inside the shell script

When my script deals with large input files like 22Gb or 18 GB the basic commands like sort or join fails when run from inside the shell scripts. Can there be any specific reason for this?

For e.g.
sort -u -t "," -k1,1 a.csv > a.csv.uniq"
sort -u -t "," -k1,1 b.csv > b.csv.uniq"

The first sort fails in the midway and begins the sort on the b.csv without throwing any error.

When run from the command line they run perfectly..they are giving me a problem only when they are run from a shell script. Does the HUGE file size has anything to do with this??
# 2  
Old 06-02-2009
Quote:
Originally Posted by esha
When my script deals with large input files like 22Gb or 18 GB the basic commands like sort or join fails when run from inside the shell scripts. Can there be any specific reason for this?

For e.g.
sort -u -t "," -k1,1 a.csv > a.csv.uniq"
sort -u -t "," -k1,1 b.csv > b.csv.uniq"

The first sort fails in the midway and begins the sort on the b.csv without throwing any error.

When run from the command line they run perfectly..they are giving me a problem only when they are run from a shell script. Does the HUGE file size has anything to do with this??
thats because there is not enough space in
/var/tmp area as sort by default sort uses /var/tmp area
mention directory where you have more than 22GB area with sort command
Code:
sort -T directorypath -u -t "," -k1,1 a.csv > a.csv.uniq

# 3  
Old 06-02-2009
Quote:
Originally Posted by vidyadhar85
thats because there is not enough space in
/var/tmp area as sort by default sort uses /var/tmp area
mention directory where you have more than 22GB area with sort command
Code:
sort -T directorypath -u -t "," -k1,1 a.csv > a.csv.uniq

i changed the code to

sort -T /home/esha/tmp/ -u -t "," -k1,1 a.csv > a.csv.uniq
sort -T /home/esha/tmp/ -u -t "," -k1,1 b.csv > b.csv.uniq

and I have abt 120GB free. But still the problem is occurs...
# 4  
Old 06-02-2009
Try it with more steps per file, an example:

Code:
awk '/^[a-hA-H]/' file | sort .... > file1
awk '/^[i-pI-P]/' file | sort .... > file2
awk '/^[q-zq-Z]/' file | sort .... > file3

cat file1 file2 file3 > csv.uniq

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] Usage of shell commands inside a C program

Hi I have a program int main(int srgc, char *argv) { for(int i=1; i<50; i++) { system("dd if=/dev/zero of=file$i bs=1024 count=$i"); } return 0; } My doubt is how to use the "$i" value inside C code Please help (2 Replies)
Discussion started by: Priya Amaresh
2 Replies

2. Shell Programming and Scripting

Shell script with mutiple steps/commands, on UNIX servers

Hi, I wrote a simple script, which will call other scripts or run commands on a UNIX server. my script has multiple steps/commands with some delay in between. I usually get some email notifications after the successful execution of each step. **My intention is to get email alerts when it is... (5 Replies)
Discussion started by: System Admin 77
5 Replies

3. Shell Programming and Scripting

RMAN commands inside crontab shell script

Hello I'm trying to write simple script to delete archive logs for RMAN, unfortunately it's not working, I tried two way to do that: #!/bin/ksh echo "Start ....." rman target=/ << EOF RUN { delete force noprompt archivelog until time 'sysdate-10'; } EXIT; EOF echo "END ..." echo... (6 Replies)
Discussion started by: samer.odeh
6 Replies

4. UNIX for Dummies Questions & Answers

File operations are failing inside the script

Hi, does any one know the environmental parameter that I have to set so as to make sure the file operations run properly within the script. right now when I am doing a cat from within the script nothing happens, same is the case when I do a grep. when I am doing awk '{print $0 }' its printing... (1 Reply)
Discussion started by: ahmedwaseem2000
1 Replies

5. Shell Programming and Scripting

Need help embedding Unix commands in a shell script

Hi Folks, I have a text file which may or may not have any data. I would like to email the file, via a Korn shell script, if the file is not empty. I am fiddling around with the wc -l command, but no luck so far. The pseudo code is as follows count=`wc -l test.txt` if cat test.txt... (4 Replies)
Discussion started by: rogers42
4 Replies

6. Shell Programming and Scripting

Error while using sqlplus command inside 'if' condition in an unix shell script

Hi all, I am using the below given sqlplus command in my unix script to invoke a stored procedure which returns a value .It works fine. RET_CODE=$(/opt/oracle/product/10.2.0.4.CL/bin/sqlplus -S $USER/$PASSWD@$DB_NAME <<EOF EXEC MY_PKG.MY_SP (:COUNT); PRINT COUNT; commit; ... (6 Replies)
Discussion started by: Shri123
6 Replies

7. UNIX for Advanced & Expert Users

Serializing script Failing for more commands

I have a reqirement to serialise various rsh scripts that hit my server from an external scheduler. No matter how many scripts come via rsh, only one should execute at a time and others should wait. I have made the scheduler make a request to my shell script with the command to be run as a... (4 Replies)
Discussion started by: nkamatam
4 Replies

8. Shell Programming and Scripting

How to use ftp commands inside shell script? Help please

Dears, I'm new in shell scripting and i need your help, i would like to know how can i create a script to ftp to a certain unix/linux machine/server IP address and get a file for example without user intervention? How can i force the script to use a certain username and password to access this... (4 Replies)
Discussion started by: Dendany83
4 Replies

9. Shell Programming and Scripting

Passing UNIX commands inside sed

Hi, In sed, is it possible to match patterns by directly executing UNIX commands inside sed? For e.g. - sed "s/`cat file.txt | cut -d "|" -f2`/replace_string" Will the above command work? My expectation is to search for the second field in file.txt (file delimited by | ) and replace... (10 Replies)
Discussion started by: devanathann
10 Replies

10. Shell Programming and Scripting

How to run unix commands in a new shell inside a shell script?

Hi , I am having one situation in which I need to run some simple unix commands after doing "chroot" command in a shell script. Which in turn creates a new shell. So scenario is that - I need to have one shell script which is ran as a part of crontab - in this shell script I need to do a... (2 Replies)
Discussion started by: hkapil
2 Replies
Login or Register to Ask a Question