performance variation between two commands


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers performance variation between two commands
# 1  
Old 08-15-2009
performance variation between two commands

does it make any difference in terms of performance while using any of the below mentioned code for the same requirement which processes continuously coming files in the I/P directory .

Please provide ur viewws


ls -tr $SAPRESPONSEGOFILE | sed "s/go/dat/g" |
while read SAPRESPONSEFILES
do

echo "File is ${SAPRESPONSEFILES##*/}"
done

_____________________________________________________
for SAPRESPONSEFILES in `ls $SAPRESPONSEGOFILE | sed "s/go/dat/g"`
do
echo "file is ${SAPRESPONSEFILES##*/}

done
__________________________________________
# 2  
Old 08-15-2009
In your case I don't think it will make any performance difference..
its all depend what you are gonna do inside that loop....
# 3  
Old 08-15-2009
Both technically create the same amount of processes. There may be a small performance increase in the former since it doesn't have to wait for ls to finish completely, but there is a bigger advantage not performance-related: it can handle an arbitrarily large number of files, where the backtick version can only handle the maximum number of arguments allowed by the shell.

Last edited by Corona688; 08-15-2009 at 02:53 PM..
# 4  
Old 08-16-2009
Don't know why you have started another thread on this subject. Your original performance issue was about whether sorting by date was a greater performance hit then sorting by name.

Code:
ls -tr $SAPRESPONSEGOFILE | sed "s/go/dat/g" |
while read SAPRESPONSEFILES
do
          echo "File is ${SAPRESPONSEFILES##*/}"
done

As other correspondents remark the "while" construct can deal with any number of files. However, only ONE filename is presented in each iteration:
I still recommend specifying the "-1" parameter (hyphen one).

Code:
ls -1tr $SAPRESPONSEGOFILE | sed "s/go/dat/g" |
while read SAPRESPONSEFILES
do
          echo "File is ${SAPRESPONSEFILES}"
done

If files are continuously arriving in the directory this can create issues with embyonic files (i.e. files which are part-written). Does your process have in intermediate name for files while they are being written?

Last edited by methyl; 08-16-2009 at 12:33 PM.. Reason: indent
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

[Solved] Slight variation from the desired results

Hello, I am writing a small one liner script to display the tables in my database. I am working with Centos 5.5 and postgresql the command is "psql -c "\dt" | awk '{print$3}'" I just want the 3rd column from the result set, but now the problem is I am getting the third column but with... (3 Replies)
Discussion started by: nnani
3 Replies

2. Shell Programming and Scripting

awk variation question

I have a file like this: ASSPASVFETQY,hTRBV12-4,hTRBJ2-5,2 ASSPASTGGDYGYT,hTRBV18,hTRBJ1-2,2 ASSPASGDGYT,hTRBV5-1,hTRBJ1-2,2 ASSPASFPEDTQY,hTRBV27,hTRBJ2-3,2 ASSPARVNYGYT,hTRBV5-1,hTRBJ1-2,2 ASSPARTSGGLNEQF,hTRBV6-4,hTRBJ2-1,2 ASSPARQSYNEQF,hTRBV11-1,hTRBJ2-1,2... (4 Replies)
Discussion started by: xshang
4 Replies

3. UNIX for Dummies Questions & Answers

scp shows size variation

Hi i have folder of 26 GB on server A and want to copy to server B .i used the below commands to check file size and scp copy du -h /folder : its shows 26G on server A from server B: scp -r user@serverA:/folder/* ./copying got initiated and i am checking the file size on server B... (7 Replies)
Discussion started by: rakeshkumar
7 Replies

4. AIX

HACMP: difference between 'cl' commands and 'cli' commands

Hi all, I'm new in this forum. I'm looking for the difference between the HACMP commands with the prefix "cl" and "cli". The first type are under /usr/es/sbin/cluster/sbin directory and the second are under /usr/es/sbin/cluster/cspoc directory. I know that the first are called HACMP for AIX... (0 Replies)
Discussion started by: peppix
0 Replies

5. Solaris

Performance difference between commands

Looking at the performance hit on my server, does it matter wich command I run? client # rsh server tar –cf - . | tar –cv –f – or server # tar –cf – . | rsh client ‘cd target && tar –xv -f –‘ I think it doesn't really matter because both command strings involve a tar being run on... (4 Replies)
Discussion started by: petervg
4 Replies

6. UNIX for Dummies Questions & Answers

top's USER column width variation

hello, does anyone know how to expand the column width so it could contain full USER cell and not cut it in top ? Now it has eleven symbols but I can see only eight actualy I found only PID, PPID and %CPU columns variation possibilities in changelog (procps v.3.2.5). thanks in advance. (1 Reply)
Discussion started by: bugs_moran
1 Replies

7. Shell Programming and Scripting

Can BASH execute commands on a remote server when the commands are embedded in shell

I want to log into a remote server transfer over a new config and then backup the existing config, replace with the new config. I am not sure if I can do this with BASH scripting. I have set up password less login by adding my public key to authorized_keys file, it works. I am a little... (1 Reply)
Discussion started by: bash_in_my_head
1 Replies

8. UNIX for Dummies Questions & Answers

Commands performance measurement

Hi, Actually i wanted to check out the process time for the execution of commands on unix, i looking for the script which can include all commands which are to be executed on the system and i need to get the time for executing each command, can somebody help me Thanks & Regards Murali (1 Reply)
Discussion started by: hsmuralidhara
1 Replies

9. News, Links, Events and Announcements

Announcing collectl - new performance linux performance monitor

About 4 years ago I wrote this tool inspired by Rob Urban's collect tool for DEC's Tru64 Unix. What makes this tool as different as collect was in its day is its ability to run at a low overhead and collect tons of stuff. I've expanded the general concept and even include data not available in... (0 Replies)
Discussion started by: MarkSeger
0 Replies

10. Programming

code that reads commands from the standard i/p and executes the commands

Hello all, i've written a small piece of code that will read commands from standard input and executes the commands. Its working fine and is execting the commands well. Accepting arguments too. e.g #mkdir <name of the directory> The problem is that its not letting me change the directory i.e... (4 Replies)
Discussion started by: Phrozen Smoke
4 Replies
Login or Register to Ask a Question