Sponsored Content
Top Forums Shell Programming and Scripting Check my script and correct the find command if wrong Post 302570322 by anuragpgtgerman on Thursday 3rd of November 2011 03:21:36 AM
Old 11-03-2011
No this is not working please see my code

Code:
show_command()
{
 while [ $# -gt 0 ]
 do
  echo -e "\n";
  echo '=======================================================================================================================';
  echo "Command/s used for getting the list of files/output below is/are as follows:"; echo;
  echo "\$ ${1}"; echo;
  echo '=======================================================================================================================';
################################################################################################
## To make $n --> $n-1 i.e $1 will become $2 once the below "shift" command will be called.   ##
################################################################################################
  shift;
 done
}
SourceCodelogs()
{
cmd="find /efare1/home/qabuild/rohit -maxdepth 1 -type d -name "EFS*" -o -name "HOTFIX*" -mtime -5 -print 2>/dev/null";
#cmd="find /efare1/home/qabuild/rohit -maxdepth 1 \( -name "EFS*" -o -name "HOTFIX*" \) -mtime -5 -type d -print 2>/dev/null";
#cmd="find /efare1/home/qabuild/rohit -maxdepth 1 -type d -name "*_SOURCE" -mtime +5 -print 2>/dev/null";
 show_command "${cmd}";
 for TARGET in `eval ${cmd}`
 do
  echo "1 --> * removing... ${TARGET}"
 # rm -frv ${TARGET}
 done
}
SourceCodelogs

Code:
drwxr-xr-x 3 qabuild denccefs  4096 Sep 23 21:36 EFS110929A_SOURCE/
-rwxrwxr-x 1 qabuild denccefs   242 Oct 31 09:29 tt1*
-rwxrwxr-x 1 qabuild denccefs   943 Oct 31 11:08 FetchCode*
-rwxrwxr-x 1 qabuild denccefs  7250 Nov  1 08:12 FetchCode1*
drwxr-xr-x 3 qabuild denccefs  4096 Nov  2 06:49 EFS111027B_SOURCE/
-rwxrwxr-x 1 qabuild denccefs  7982 Nov  2 13:10 FetchCode2*
-rwxrwxr-x 1 qabuild denccefs  8083 Nov  2 15:25 FetchCode3*
drwxr-xr-x 3 qabuild denccefs  4096 Nov  2 17:18 EFS111013B_SOURCE/
-rw-rw-r-- 1 qabuild denccefs 60603 Nov  2 17:21 Default.aspx
-rw-rw-r-- 1 qabuild denccefs    11 Nov  3 03:24 NGGF_Release.txt
drwxrwxr-x 2 qabuild denccefs  4096 Nov  3 03:33 Temp/
-rwxrwxr-x 1 qabuild denccefs  8170 Nov  3 07:17 FetchCode4*
-rwxrwxr-x 1 qabuild denccefs  1261 Nov  3 07:18 ttt1*

The above is the directory where EFS directory lies

Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How can I check that a password is correct?

Hi there, There's something I don't understand. The same string does not give the same md5 hash everytime. I wanted to find a way to check someone's password but the following script obviously shows that it's not possible that way : ks354286:~# user=foo ks354286:~# pw=$(mkpasswd -H md5... (3 Replies)
Discussion started by: chebarbudo
3 Replies

2. UNIX for Advanced & Expert Users

what is wrong with this find command

i am trying to find the files which are more than 100MB and it was created 10 days ago. find /lola/loaded -size +102400 -mtime -10 -print | xargs ls -ltr -rw-rw-r-- 1 lola_adm gdrmp 82054170 Jun 23 06:17 /lola/loaded/ILMEMBER20090622.txt -rw-rw-r-- 1 lola_adm gdrmp 652080494 Jun 24... (3 Replies)
Discussion started by: sudhiroracle
3 Replies

3. Shell Programming and Scripting

Wrong output in find command

Hi guys - I am trying a small script to tell me if there is a file that exists less than 1k. It should report ERROR, otherwise the check is good. I wrote this script down, however it never runs in the if/then statement. It always returns the echo ERROR. MYSIZE=$(find /home/student/dir1... (8 Replies)
Discussion started by: DallasT
8 Replies

4. Shell Programming and Scripting

WORD SEARCH - CHECK IF CORRECT!

Im currently working on a Script using PICO editor, the scripts purpose is : When you typed a certain "word" and press enter, All directories, Script, and any other files that contain that "word" will be displayed.. for example i typed "DOG".. all executable script, Directories, and any other... (3 Replies)
Discussion started by: jenimesh19
3 Replies

5. Shell Programming and Scripting

Not correct processing of “\ “ in names of dirs inside shell script (tar command - system backup scr

Hello, Recently, I've started with shell scripting, and decided to write a script for my system backup using tar. When I was dealing with tar execution inside shell script I found this, inside shell we have the following code: tar $TAR_PARAMS $ARCHIVE_FILE $EXCLUDE $BACKUP_STARTwith... (6 Replies)
Discussion started by: ilnar
6 Replies

6. Solaris

run a service via startup script (correct me if I am wrong)

Environment Solaris 9 I have configured the Solaris9 as NTP client in which Solaris9 is syncing the time with a windows2008 R2 Server which is runing fine. Now I want that the xntpd service should start at startup. I did this via a script. Kindly correct if I did any thing wrong: 1.)Made... (9 Replies)
Discussion started by: z_haseeb
9 Replies

7. Shell Programming and Scripting

perl script to check the mail ids in the correct format or not

Hi Folks, I have few mailids in a text file and need to check whether the mailid is in correct format or not. If just to check whether the string is a mailid or not there is a perl module Email::Valid to do the business or we can implement our own logic. But the mail_ids I am having is... (4 Replies)
Discussion started by: giridhar276
4 Replies

8. Shell Programming and Scripting

How to check if date format is correct?

Hi! how do i know if the input is the same as the required date format? the date should be dd/mm/YYYY ex. 2/3/2012 or 15/11/2012 all the following conditions must return an error: *input of string *day is > 31 or < 1 *month is > 12 or < 1 *year is < 2013 suppose the date format is stored... (1 Reply)
Discussion started by: angilulu
1 Replies

9. Shell Programming and Scripting

Shell script to find the wrong filename in a path and raise a trap for it

Example: I have server name A with an IP : 125.252.235.455 I have an username /password to login into this server under SSH connection In this server i have a path /apps/user/filename(Big.txt) Everyday we used to get the filename as Big.txt. I want a shell script to monitor this path... (4 Replies)
Discussion started by: ChandruBala73
4 Replies

10. Shell Programming and Scripting

Same sed code prints(p) correct, but writtes(w) wrong output

Dear all, I am using sed as an alternative to grep in order to get a specific line from each of multiple files located in the same directory. I am using sed because it prints the lines in the correct order (unlike grep). When I write sed code that prints out the output I get it correct, but... (1 Reply)
Discussion started by: JaNaJaNa
1 Replies
GIT-SH-SETUP(1) 						    Git Manual							   GIT-SH-SETUP(1)

NAME
       git-sh-setup - Common Git shell script setup code

SYNOPSIS
       . "$(git --exec-path)/git-sh-setup"

DESCRIPTION
       This is not a command the end user would want to run. Ever. This documentation is meant for people who are studying the Porcelain-ish
       scripts and/or are writing new ones.

       The git sh-setup scriptlet is designed to be sourced (using .) by other shell scripts to set up some variables pointing at the normal Git
       directories and a few helper shell functions.

       Before sourcing it, your script should set up a few variables; USAGE (and LONG_USAGE, if any) is used to define message given by usage()
       shell function. SUBDIRECTORY_OK can be set if the script can run from a subdirectory of the working tree (some commands do not).

       The scriptlet sets GIT_DIR and GIT_OBJECT_DIRECTORY shell variables, but does not export them to the environment.

FUNCTIONS
       die
	   exit after emitting the supplied error message to the standard error stream.

       usage
	   die with the usage message.

       set_reflog_action
	   Set GIT_REFLOG_ACTION environment to a given string (typically the name of the program) unless it is already set. Whenever the script
	   runs a git command that updates refs, a reflog entry is created using the value of this string to leave the record of what command
	   updated the ref.

       git_editor
	   runs an editor of user's choice (GIT_EDITOR, core.editor, VISUAL or EDITOR) on a given file, but error out if no editor is specified
	   and the terminal is dumb.

       is_bare_repository
	   outputs true or false to the standard output stream to indicate if the repository is a bare repository (i.e. without an associated
	   working tree).

       cd_to_toplevel
	   runs chdir to the toplevel of the working tree.

       require_work_tree
	   checks if the current directory is within the working tree of the repository, and otherwise dies.

       require_work_tree_exists
	   checks if the working tree associated with the repository exists, and otherwise dies. Often done before calling cd_to_toplevel, which
	   is impossible to do if there is no working tree.

       require_clean_work_tree <action> [<hint>]
	   checks that the working tree and index associated with the repository have no uncommitted changes to tracked files. Otherwise it emits
	   an error message of the form Cannot <action>: <reason>. <hint>, and dies. Example:

	       require_clean_work_tree rebase "Please commit or stash them."

       get_author_ident_from_commit
	   outputs code for use with eval to set the GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL and GIT_AUTHOR_DATE variables for a given commit.

       create_virtual_base
	   modifies the first file so only lines in common with the second file remain. If there is insufficient common material, then the first
	   file is left empty. The result is suitable as a virtual base input for a 3-way merge.

GIT
       Part of the git(1) suite

Git 2.17.1							    10/05/2018							   GIT-SH-SETUP(1)
All times are GMT -4. The time now is 02:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy