Sponsored Content
Top Forums Shell Programming and Scripting Anyone have better way to remove ls from this function? Post 302991965 by Chubler_XL on Sunday 19th of February 2017 02:37:19 PM
Old 02-19-2017
If you happy with Percent complete being accurate to within 1% you can also save spawning bc like replace this:

Code:
tot=$(printf "%s\n" *.${src_ext} | wc -l)
for i in `ls *.${src_ext} | sort -k2 -t_ -n`
do

    //lots of stuff that takes a while here

    printf "percentDone %d\n" $((100*++k / tot))
done

or, using an array when can also get rid of wc -l:

Code:
F=( *.${src_ext} )
tot=${#F[@]}
for i in "${F[@]}"
do

    //lots of stuff that takes a while here

    printf "percentDone %d\n" $((100*++k / tot))
done


Last edited by Chubler_XL; 02-19-2017 at 03:42 PM..
This User Gave Thanks to Chubler_XL For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing global variable to a function which is called by another function

Hi , I have three funcions f1, f2 and f3 . f1 calls f2 and f2 calls f3 . I have a global variable "period" which i want to pass to f3 . Can i pass the variable directly in the definition of f3 ? Pls help . sars (4 Replies)
Discussion started by: sars
4 Replies

2. Shell Programming and Scripting

Return a value from called function to the calling function

I have two scripts. script1.sh looks -------------------------------- #!/bin/bash display() { echo "Welcome to Unix" } display ----------------------------- Script2.sh #!/bin/bash sh script1.sh //simply calling script1.sh ------------------------------ (1 Reply)
Discussion started by: mvictorvijayan
1 Replies

3. Shell Programming and Scripting

SHELL SCRIPT Function Calling Another Function Please Help...

This is my function which is creating three variables based on counter & writing these variable to database by calling another function writeRecord but only one record is getting wrote in DB.... Please advise ASAP...:confused: function InsertFtg { FTGSTR="" echo "Saurabh is GREAT $#" let... (2 Replies)
Discussion started by: omkar.sonawane
2 Replies

4. Shell Programming and Scripting

Function to remove the directories from PATH variable

Hello, From the URL https://www.unix.com/shell-programming-scripting/121303-remove-path-path-environment-variable-2.html I got a function to remove the directories from a path. but looks like this isnt quite working.. i am also not able to post the comments in the thread as it is closed. ... (6 Replies)
Discussion started by: satishkumar432
6 Replies

5. Shell Programming and Scripting

Help to Modify File Name in each function before calling another function.

I have a script which does gunzip, zip and untar. Input to the script is file name and file directory (where file is located) I am reading the input parameters as follows: FILENAME=$1 FILEDIR=$2 I have created 3 functions that are as follows: 1) gunzip file 2) unzip file... (2 Replies)
Discussion started by: pinnacle
2 Replies

6. Shell Programming and Scripting

Will files, creaetd in one function of the same script will be recognized in another function?

Dear All. I have a script, which process files one by one. In the script I have two functions. one sftp files to different server the other from existing file create file with different name. My question is: Will sftp function recognize files names , which are created in another... (1 Reply)
Discussion started by: digioleg54
1 Replies

7. UNIX for Beginners Questions & Answers

awk function to remove lines that contain contents of another file

Hi, I'd be grateful for your help with the following. I have a file (file.txt) with 10 columns and about half a million lines, which in simplified form looks like this: ID Col1 Col2 Col3.... a 4 2 8 b 5 6 1 c 8 4 1 d... (4 Replies)
Discussion started by: aberg
4 Replies

8. Shell Programming and Scripting

Need help on awk for printing the function name inside each function

Hi, I am having script which contains many functions. Need to print each function name at the starting of the function. Like below, functionname() { echo "functionname" commands.... } I've tried like below, func=`grep "()" scriptname | cut -d "(" -f1` for i in $func do nawk -v... (4 Replies)
Discussion started by: Sumanthsv
4 Replies

9. UNIX for Beginners Questions & Answers

DB2 Query modification to remove duplicate values using LISTAGG function

I am using DB2 v9 and trying to get country values in comma seperated format using below query SELECT distinct LISTAGG(COUNTRIES, ',') WITHIN GROUP(ORDER BY EMPLOYEE) FROM LOCATION ; Output Achieved MEXICO,UNITED STATES,INDIA,JAPAN,UNITED KINGDOM,MEXICO,UNITED STATES The table... (4 Replies)
Discussion started by: Perlbaby
4 Replies

10. Shell Programming and Scripting

Function - Make your function return an exit status

Hi All, Good Day, seeking for your assistance on how to not perform my 2nd, 3rd,4th etc.. function if my 1st function is in else condition. #Body function1() { if then echo "exist" else echo "not exist" } #if not exist in function1 my all other function will not proceed.... (4 Replies)
Discussion started by: meister29
4 Replies
BTRECORD(8)															       BTRECORD(8)

NAME
btrecord - recreate IO loads recorded by blktrace SYNOPSIS
Usage: btrecord [ options ] <dev...> DESCRIPTION
The btrecord and btreplay tools provide the ability to record and replay IOs captured by the blktrace utility. Attempts are made to main- tain ordering, CPU mappings and time-separation of IOs. The blktrace utility provides the ability to collect detailed traces from the kernel for each IO processed by the block IO layer. The traces provide a complete timeline for each IO processed, including detailed information concerning when an IO was first received by the block IO layer -- indicating the device, CPU number, time stamp, IO direction, sector number and IO size (number of sectors). Using this information, one is able to replay the IO again on the same machine or another set up entirely. The basic operating work-flow to replay IOs would be something like: - Run blktrace to collect traces. Here you specify the device or devices that you wish to trace and later replay IOs upon. Note: the only traces you are interested in are QUEUE requests -- thus, to save system resources (including storage for traces), one could specify the -a queue command line option to blktrace. - While blktrace is running, you run the workload that you are interested in. - When the work load has completed, you stop the blktrace utility (thus saving all traces over the complete workload). - You extract the pertinent IO information from the traces saved by blktrace using the btrecord utility. This will parse each trace file created by blktrace, and crafty IO descriptions to be used in the next phase of the workload processing. - Once btrecord has successfully created a series of data files to be processed, you can run the btreplay utility which attempts to generate the same IOs seen during the sample workload phase. OPTIONS
-d <dir> --input-directory=<dir> Set input directory. This option requires a single parameter providing the directory name for where input files are to be found. The default directory is the current directory (.). -D <dir> --output-directory=<dir> Set output directory. This option requires a single parameter providing the directory name for where output files are to be found. The default directory is the current directory (.). -F --find-traces Find trace files automatically This option instructs btreplay to go find all the trace files in the directory specified (either via the -d option, or in the default directory (.). -h --help Show help and exit. -V --version Show version number and exit. -m <nanoseconds> --input-base=<nanoseconds> The -m option requires a single parameter which specifies an amount of time (in nanoseconds) to include in any one bunch of IOs that are to be processed. The smaller the value, the smaller the number of IOs processed at one time -- perhaps yielding in more realis- tic replay. However, after a certain point the amount of overhead per bunch may result in additional real replay time, thus yield- ing less accurate replay times. The default value is 10,000,000 nanoseconds (10 milliseconds). -M <num> --max-pkts=<num> Set maximum number of packets per bunch. The -M option requires a single parameter which specifies the maximum number of IOs to store in a single bunch. As with the -m option, smaller values may or may not yield more accurate replay times. The default value is 8, with a maximum value of up to 512 being supported. -o <basename> --output-base=<basename> Set base name for output files. Each output file has 3 fields: 1. Device identifier (taken directly from the device name of the blktrace output file). 2. btrecord base name -- by default ``replay''. 3. The CPU number (again, taken directly from the blktrace output file name). This option requires a single parameter that will override the default name (replay), and replace it with the specified value. -v --verbose Enable verbose output. This option will output some simple statistics at the end of a successful run. Example output is: sdab:0: 580661 pkts (tot), 126030 pkts (replay), 89809 bunches, 1.4 pkts/bunch sdab:1: 2559775 pkts (tot), 430172 pkts (replay), 293029 bunches, 1.5 pkts/bunch sdab:2: 653559 pkts (tot), 136522 pkts (replay), 102288 bunches, 1.3 pkts/bunch sdab:3: 474773 pkts (tot), 117849 pkts (replay), 69572 bunches, 1.7 pkts/bunch The meaning of the columns is: 1. The first field contains the device name and CPU identifier. Thus: sdab:0: means the device sdab and traces on CPU 0. 2. The second field contains the total number of packets processed for each device file. 3. The next field shows the number of packets eligible for replay. 4. The fourth field contains the total number of IO bunches. 5. The last field shows the average number of IOs per bunch recorded. AUTHORS
btrecord was written by Alan D. Brunelle. This man page was created from the btreplay documentation by Bas Zoetekouw. REPORTING BUGS
Report bugs to <linux-btrace@vger.kernel.org> COPYRIGHT
Copyright (C) 2007 Alan D. Brunelle, Alan D. Brunelle and Nathan Scott. This is free software. You may redistribute copies of it under the terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the extent permitted by law. This manual page was created for Debian by Bas Zoetekouw. It was derived from the documentation provided by the authors and it may be used, distributed and modified under the terms of the GNU General Public License, version 2. On Debian systems, the text of the GNU General Public License can be found in /usr/share/common-licenses/GPL-2. SEE ALSO
The full documentation for btreplay can be found in /usr/share/doc/blktrace on Debian systems. blktrace (8), blkparse (1), btreplay (8) blktrace git-20071207142532 December 8, 2007 BTRECORD(8)
All times are GMT -4. The time now is 03:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy