I'm pretty new to bash scripting, so this should be a pretty easy question to solve.
For the last few hours, I've been creating a script that will list some of the following (based on a path I specify):
# of directories
# of files
# of executable files
files older than 365 days
and more...
What I need help with doing is coming up with a "find" command that will do the above items (and more) by passing over all my specified directory files ONLY ONCE.
When running my script, I'll do:
In my bash file, if no path is specified, then I'll return an exit code of 1.
I'm guessing I'm going to need to do something like this:
Then towards the end of my script I'll do:
Hopefully this'll be an easier to solve question. I appreciate any help anybody may be able to give me. Thank you most kindly in advance!
Please review the rules, which you agreed to when you registered, if you have not already done so.
If you did not post homework, please explain the company you work for and the nature of the problem you are working on. And, tell us what operating system you're using. We would assume that by now you have tried the code you have shown us and know that it produces syntax errors instead of giving you the results you want. We would also hope that you have looked at the find man page (using the command man find) to determine the correct syntax and know that the find command does not set variables to counts of selected pathnames.
If you did post homework in the main forums, please review the guidelines for posting homework and repost in the proper forum.
I am trying find files in sub dir with certain tags using tag command, and add the period to the beginning. I can't use chflags hidden {} cause it doesn't add period to the beginning of the string for web purpose. So far with my knowledge, I only know mdfind or tag can be used to search files with... (6 Replies)
These three finds worked as expected:
$ find . -iname "*.PDF"
$ find . -iname "*.PDF" \( ! -name "*_nobackup.*" \)
$ find . -path "*_nobackup*" -prune -iname "*.PDF"
They all returned the match:
./folder/file.pdf
:b:
This find returned no matches:
$ find . -path "*_nobackup*" -prune... (3 Replies)
Guys,
i've got hundreds of C programs in my ~/devel/ directory and sub-directories. is there a way i can use grep -r followed by some zsh, sh, bash, to find some code that starts with "&foo" or something similar?
thanks in advance! (9 Replies)
Basically I want to shorten URLs on my html pasting site (pasteht.ml), by using "/~a1Pha" instead of "/paste/a1Pha". The ID is 5 numbers and letters, both cases.
For example:
/~idnum serves /paste/idnum.htm
/=idnum serves /paste/idnum.htm
/paste/idnum redirects to /~idnum (to update any old... (0 Replies)
I have a bunch of random character lines like ABCEDFG. I want to find all lines with "A" and then change any "E" to "X" in the same line. ALL lines with "A" will have an "X" somewhere in it. I have tried sed awk and vi editor. I get close, not quite there. I know someone has already solved this... (10 Replies)
I am trying to find out which files in a group of files have lines ending in r. What I have is this:
cat /tmp/*RECORDS| if grep r$>/dev/null; then echo "yes";else echo"no";fi
Records is more than one file. There are the following files
TEST-RECORDS
/volume/testing
/volume/programs
... (2 Replies)
Hi All,
I am new here but I have a scripting question that I can't seem to figure out with the "find" cmd.
What I am trying to do is to only have to run a single find cmd parsing the directories and output the different file types to induvidual files and I have been running into problems.... (3 Replies)
Hi all.
I have a .txt file that I need to sort it
My file is like:
1- 88 chain0 MASTER (FF-TE) FFFF 1962510 /TCK T FD2TQHVTT1 /jtagc/jtag_instreg/updateinstr_reg_1 dff1 (TI,SO)
2- ... (10 Replies)
Dear friends,
please tell me how to find the files which are existing in the current directory, but it sholud not search in the sub directories..
it is like this,
current directory contains
file1, file2, file3, dir1, dir2
and dir1 conatins
file4, file5
and dir2 contains
file6,... (9 Replies)