Sponsored Content
Top Forums Shell Programming and Scripting Find command when there exist many files Post 303013230 by kristinu on Sunday 18th of February 2018 07:13:10 AM
Old 02-18-2018
Displaying percentage when it changes

I want to display the percentage when it changes by 3% and only print
then keeping the cursor on the same line.

Some suggestions would help me.

---------- Post updated at 07:03 AM ---------- Previous update was at 06:56 AM ----------

I have done it this way, which looks good

Code:
i=0
for f in $(find . -type f); do
  #echo "+ $f"
  i=$((i+1))
  percent=$(awk "BEGIN { pc=100*${i}/${flcnt}; j=int(pc); print (pc-j<0.5)?j:j+1 }")
  #echo "$percent"
  echo -e "\r${percent}%\c"
  #${dir_mseed2sac}/mseed2sac $f
done

---------- Post updated at 07:13 AM ---------- Previous update was at 07:03 AM ----------

The final thing I would like to do is have a progress bar enclosed by [ ]
and using stars to show the completion. The total number of stars should
be 60 for completion

Example:

Code:
[**********                                    ] 10%

Code:
i=0
nstars=0
for f in $(find . -type f); do
  #echo "+ $f"
  i=$((i+1))
  percent=$(awk "BEGIN { pc=100*${i}/${flcnt}; j=int(pc); print (pc-j<0.5)?j:j+1 }")
  #echo "$percent"
  echo -e "\r${percent}%\c"
  nstars=$((percent*0.6))
  echo -e "[*****                         ]"
  #${dir_mseed2sac}/mseed2sac $f
done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can I find wether a particular file exist and size greater than zero...help please

Can I find wether a particular file exist and size greater than zero in one line command. similar to this if && something in one if test .... e.g. if 1.) is it possible ? ... if yes how 2.) what would be the return type in case there is success or failure. I mean if both are... (4 Replies)
Discussion started by: guhas
4 Replies

2. UNIX for Dummies Questions & Answers

Find in file. Does this exist under UNIX?

Hello, I have the following problem. I know there is a file somewhere on a UNIX machine that contains a string, but I don't know where. With the "grep" command, I can look into a file but only if I'm located in the correct directory. With the "find" command, I can search across directories... (2 Replies)
Discussion started by: scampsd
2 Replies

3. Shell Programming and Scripting

Little bit weired : Find files in UNIX w/o using find or where command

Yes , I have to find a file in unix without using any find or where commands.Any pointers for the same would be very helpful as i am beginner in shell scritping and need a solution for the same. Thanks in advance. Regards Jatin Jain (10 Replies)
Discussion started by: jatin.jain
10 Replies

4. UNIX for Dummies Questions & Answers

How to find if file exist in directory using *

Hi, I know how to use the test command ( ...) to find a single given name file. However, I have a case in which I have a directory with one file and one sub-directory. I know that the file starts with "fub". The command doesn't work if i call the file "fub*" as it doesn't understand I meant a... (2 Replies)
Discussion started by: buj
2 Replies

5. Shell Programming and Scripting

Find out whether files exist.

I have the following data stored in a file. 1 /home/file13 /home/file2 2 /home/file41 /home/file654 3 /home/file61 /home/file45 4 /home/file81 /home/file43 ... I want to print the first column provided the files represented by the second and third column exist. How to do that? (3 Replies)
Discussion started by: kevintse
3 Replies

6. Shell Programming and Scripting

what is the find to command to find the files created last 30 days

what is the find to command to find the files created last 30 days (5 Replies)
Discussion started by: rajkumar_g
5 Replies

7. Shell Programming and Scripting

find + move if destination path does not exist

hi frnds, please help ... what will happen with below command if destination path does not exist on the system.... find /var/adm/cft* -mtime +1 -exec mv {} /global/ \ in unix its remove all my files from the system from soruce file ... how is it possbile (1 Reply)
Discussion started by: dodasajan
1 Replies

8. UNIX for Dummies Questions & Answers

Command to find files

Hi All, Can anyone give me the command to copy files from 03-Mar-2013 to 07-Mar-2013 in folder. there are nearly 40+ thousand files in directory , so I just need files from Mar 3rd to Mar 7th and copy them to a location . Need quick help pls (2 Replies)
Discussion started by: rockingvj
2 Replies

9. Shell Programming and Scripting

Find if a directory exist from a list of the path

Hello, i want to script on sh to check from a path if the directory exist and isn't empty. I explain: path is : /aaa/bbb/ccc/ccc_name/ddd/ Where the cccc_name is in a list, so i think it's $1 My command find -name /aaa/bbb/ccc/$1/ddd/ didn't work because my $1 is the same and not... (5 Replies)
Discussion started by: steiner
5 Replies

10. Shell Programming and Scripting

Find command to find a word from list of files

I need to find a word '% Retail by State' in the folder /usr/sas/reports/RetailSalesTaxallocation. When I tried like below, -bash-4.1$ cd /usr/sas/reports/RetailSalesTaxallocation -bash-4.1$ find ./ -name % Retail by State find: paths must precede expression: Retail Usage: find ... (10 Replies)
Discussion started by: Ram Kumar_BE
10 Replies
FINDRULE(1)						User Contributed Perl Documentation					       FINDRULE(1)

NAME
findrule - command line wrapper to File::Find::Rule USAGE
findrule [path...] [expression] DESCRIPTION
"findrule" mostly borrows the interface from GNU find(1) to provide a command-line interface onto the File::Find::Rule heirarchy of modules. The syntax for expressions is the rule name, preceded by a dash, followed by an optional argument. If the argument is an opening parenthesis it is taken as a list of arguments, terminated by a closing parenthesis. Some examples: find -file -name ( foo bar ) files named "foo" or "bar", below the current directory. find -file -name foo -bar files named "foo", that have pubs (for this is what our ficticious "bar" clause specifies), below the current directory. find -file -name ( -bar ) files named "-bar", below the current directory. In this case if we'd have omitted the parenthesis it would have parsed as a call to name with no arguments, followed by a call to -bar. Supported switches I'm very slack. Please consult the File::Find::Rule manpage for now, and prepend - to the commands that you want. Extra bonus switches findrule automatically loads all of your installed File::Find::Rule::* extension modules, so check the documentation to see what those would be. AUTHOR
Richard Clamp <richardc@unixbeard.net> from a suggestion by Tatsuhiko Miyagawa COPYRIGHT
Copyright (C) 2002 Richard Clamp. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
File::Find::Rule perl v5.18.2 2011-09-19 FINDRULE(1)
All times are GMT -4. The time now is 07:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy