Sponsored Content
Full Discussion: file searching...
Top Forums Shell Programming and Scripting file searching... Post 302163753 by Kaminski on Saturday 2nd of February 2008 06:12:48 AM
Old 02-02-2008
file searching...

Hi! i'm trying to do a script (i'm not an expert, as you will see...Smilie) to search files in a directory (and its subdirectories). I'd like to have something like this:

mysearch -a arg1 -b arg2 -c arg3 ecc...

I'd like to be able to search for files in different ways: for example, with

my search -n text* -u Eddie

i'd like to have all the files that begin with "text" owned by Eddie.
The options should be:
-n arg1 : search by name
-f arg2 : search by file dimension
-s arg3 : search by string
-d arg4 : search by date
-u arg5 : search by owner
etc.

I wrote these few lines (i'm not sure it's ok Smilie) to manage the options:

#!/bin/bash
if [ $# = 0 ] ; then echo "Message A" ; fi ;
while getopts n:f:s:d:u: c
do
case $c in
n ) search_by_name ;;
f ) search_by_dim ;;
........
* ) echo "Message B"
esac
done

search_by_name, search_by_dim etc. must be replaced with instructions that find files with a certain name etc.

My problem is how to combine the different options? That way i can search files by name or by string but i don't know how to search by name AND by string...Smilie I don't know if it's clear...
I know it's a stupid question but as i said i'm not an expert Smilie
Any help would be really appreciated!
Thanks!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Append a field to the end of each line of a file based on searching another file.

Hi All, I have two comma separated value(CSV) files, say FileA and FileB. The contents looks like that shown below. FileA EmpNo,Name,Age,Sex, 1000,ABC,23,M, 1001,DES,24,F, ... (2 Replies)
Discussion started by: ultimate
2 Replies

2. Shell Programming and Scripting

searching a log file and appending to a .txt file

I'm new to shell scripting and am writing a script to help me log the free memory and hd space on a server. As of now, the script just runs 'df -h' and appends the output to a file and then runs 'top' and appends the output to a log file. What I want to do, is have the script also search the... (3 Replies)
Discussion started by: enator45
3 Replies

3. Shell Programming and Scripting

Searching for Log / Bad file and Reading and writing to a flat file

Need to develop a unix shell script for the below requirement and I need your assistance: 1) search for file.log and file.bad file in a directory and read them 2) pull out "Load_Start_Time", "Data_File_Name", "Error_Type" from log file 4) concatinate each row from bad file as... (3 Replies)
Discussion started by: mlpathir
3 Replies

4. UNIX for Dummies Questions & Answers

Help with searching for a file in a directory and copying the contents of that file in a new file

Hi guys, I am a newbie here :wall: I need a script that can search for a file in a directory and copy the contents of that file in a new file. Please help me. :confused: Thanks in advance~ (6 Replies)
Discussion started by: zel2zel
6 Replies

5. Shell Programming and Scripting

Help in searching a particular string in a file name (not inside the file contents)

Dear Unix Gurus, I am new to shell scripting and in the process of learing. I am trying to find whether a file name has today's date in MMDDYYYY format. I am using the following code and it doesn't seem like working. #!/usr/bin/ksh today=$(date '+%m%d%Y') echo today: $today file=`find... (4 Replies)
Discussion started by: shankar1dada
4 Replies

6. Shell Programming and Scripting

searching a file with a specified text without using conventional file searching commands

without using conventional file searching commands like find etc, is it possible to locate a file if i just know that the file that i'm searching for contains a particular text like "Hello world" or something? (5 Replies)
Discussion started by: arindamlive
5 Replies

7. Shell Programming and Scripting

Searching file for pattern, output to file (BASH)

Hello, I'm trying to write a script in Bash to assist in pentesting. Essentially I'm looking to use a script to search for some terms in a log file and then send that key information into another file. The log files consist of HTTP and SSL information that someone creates while browsing and... (2 Replies)
Discussion started by: Sagesparten007
2 Replies

8. Shell Programming and Scripting

Searching a file inside a .tar.gz file by date

Hi, I would like to ask if there is a way to search for a file inside a .tar.gz file without extracting it? If there is, is there a way to search for that file by date? Thanks! (4 Replies)
Discussion started by: erin00
4 Replies

9. UNIX for Dummies Questions & Answers

Searching for a file...

Hi guys... Macbook Pro, OSX 10.7.5, bash... I want to search for a known file in a totally unknown location. This works perfectly:- capturepath=`find / -name 'sox' 2>/dev/null` Except it is crucyfyingly SSLLOOWW; and I mean SSLLOOWW! Is there any means of searching the entire FS quickly... (5 Replies)
Discussion started by: wisecracker
5 Replies

10. Shell Programming and Scripting

Searching the content of one file using the search key of another file

I have two files: file 1: hello.com neo.com,japan.com,example.com news.net xyz.com, telecom.net, highlands.net, software.com example2.com earth.net, abc.gov.uk file 2: neo.com example.com abc.gov.uk file 2 are the search keys to search in file 1 if any of the search key is... (3 Replies)
Discussion started by: csim_mohan
3 Replies
shevek::ristring(3)					     Library Functions Manual					       shevek::ristring(3)

NAME
shevek::ristring - shevek::ristring is identical to shevek::istring, but it uses std::string instead of Glib::ustring. SYNOPSIS
#include <iostring.hh> Public Member Functions ristring () Create a new istring with no data. ristring (std::string const &str) Create a new istring with data. void init (std::string const &str) Set new data to an existing istring. void push () Push the current position to the stack so it can be restored later. int pop (bool keep=false) Pop the last pushed position from the stack. void reset () Set the current position to 0, but don't change the stack. std::string rest () const Get remaining string. void skip (std::string::size_type p) Skip some characters. bool operator() (std::string const &format) Read a constant string from the input. template<typename T1 > bool operator() (std::string const &format, T1 &arg1) Read a string containing one argument from the input. template<typename T1 , typename T2 > bool operator() (std::string const &format, T1 &arg1, T2 &arg2) Read a string containing two arguments from the input. template<typename T1 , typename T2 , typename T3 > bool operator() (std::string const &format, T1 &arg1, T2 &arg2, T3 &arg3) Read a string containing three arguments from the input. template<typename T1 , typename T2 , typename T3 , typename T4 > bool operator() (std::string const &format, T1 &arg1, T2 &arg2, T3 &arg3, T4 &arg4) Read a string containing four arguments from the input. template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 > bool operator() (std::string const &format, T1 &arg1, T2 &arg2, T3 &arg3, T4 &arg4, T5 &arg5) Read a string containing five arguments from the input. template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 > bool operator() (std::string const &format, T1 &arg1, T2 &arg2, T3 &arg3, T4 &arg4, T5 &arg5, T6 &arg6) Read a string containing six arguments from the input. template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 > bool operator() (std::string const &format, T1 &arg1, T2 &arg2, T3 &arg3, T4 &arg4, T5 &arg5, T6 &arg6, T7 &arg7) Read a string containing seven arguments from the input. template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 > bool operator() (std::string const &format, T1 &arg1, T2 &arg2, T3 &arg3, T4 &arg4, T5 &arg5, T6 &arg6, T7 &arg7, T8 &arg8) Read a string containing eight arguments from the input. Static Public Member Functions template<typename T > static T direct (std::string const &data, std::string const &format, T def=T()) Read a variable from given data and return it. Detailed Description shevek::ristring is identical to shevek::istring, but it uses std::string instead of Glib::ustring. Member Function Documentation template<typename T > static T shevek::ristring::direct (std::string const &data, std::string const &format, Tdef = T ()) [inline, static] Read a variable from given data and return it. This allows using a shevek::istring in an expression without the need to create a new variable for it. If the input doesn't match the format, def is returned. int shevek::ristring::pop (boolkeep = false) Pop the last pushed position from the stack. If keep is true or not given, the current position is restored to the last position. If it is false, the current position is not changed. Author Generated automatically by Doxygen for libshevek from the source code. libshevek Fri May 11 2012 shevek::ristring(3)
All times are GMT -4. The time now is 08:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy