SCLISS - Simple Command LIne Search Script

Using applications, configuring, problems
Post Reply
Message
Author
User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

SCLISS - Simple Command LIne Search Script

#1 Post by 01micko »

What is SCLISS???

Well it is a Simple Command LIne Search Script

It's nothing fancy, it just searches a certain directory for a particular word or string.

It came about because I had to find something in some source code.. daunting!

It is based on a simple "grep" call. Technosaurus gave me the idea.

Plus, now I have added a basic usage of the find command to find files.

I made it for my own use but I thought I'd share it. I'm posting it here in the "users/regulars" section because it's not for everybody. It's a command line tool, but it does demonstrate that the command line can be fun. We get so used to pointing and clicking that we forget where the real power of Puppy, and all *nix for that matter lies. This script needn't be run in GUI mode, it should work fine in console mode.

If you read the script you will see how I used the different coloured texts, backgrounds and font weight. I put a link in the script.

It's quite functional for my purposes. As always, feel free to hack, improve, repost. 8)

Just untar the tarball and drop the script in your $PATH. I normally use /usr/sbin or /usr/bin for these sorts of things.

Cheers

Changelog
0.1.1 -little bug when typing dir
0.2 -just some more fun with colours and the hitlist returns the number of entries. Google look out! :lol:
-the colour layout is more organised, you could copy the table of vars to any script, or even make an *rc file for your scripts to read.
0.3 -things are evolving. Defined colours as vars to make code more human readable
-added capability to save to file, as an option
-fixed a bug with some versions of 'wc'. Sometimes the output has leading whitespace, hence 'cut' was failing. Changed call to 'awk'
-added more messages, just for fun
0.4 - added find command usage, fairly basic though.
-made a "bash_colors.rc" file installed to /etc, it can work for any shell based program. So any you can use this for your shell scripts... Please do!
_And.. because of that it's a .pet now, installs to /usr/sbin, the rc in /etc
0.5 - added line numbers to word/string search result, thx ttuuxxx
:oops: , 1 person got 0.5, it was wrong, reuploaded
Attachments
scliss-0.5.pet
latest
(4.21 KiB) Downloaded 538 times
scliss-0.4.pet
(4.18 KiB) Downloaded 719 times
scliss.png
in action
(20.16 KiB) Downloaded 1580 times
scliss-0.3.tar.gz
(1.93 KiB) Downloaded 706 times
scliss-0.2.tar.gz
(1.38 KiB) Downloaded 692 times
scliss-0.1.1.tar.gz
(990 Bytes) Downloaded 715 times
scliss.jpg
(55.37 KiB) Downloaded 1797 times
Last edited by 01micko on Mon 03 Jan 2011, 09:42, edited 9 times in total.
Puppy Linux Blog - contact me for access

User avatar
russoodle
Posts: 707
Joined: Fri 12 Sep 2008, 17:36
Location: Down-Under in South Oz

#2 Post by russoodle »

Thank you :)
[i][color=Green][size=92]The mud-elephant, wading thru the sea, leaves no tracks..[/size][/color][/i]

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#3 Post by 01micko »

russoodle wrote:Thank you :)
My pleasure Suz

It combines my Puppy Loves.. eye candy, scripting and humour, in no specific order.

New ver posted. More fun!

Cheers

Mick
Puppy Linux Blog - contact me for access

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#4 Post by 01micko »

Version 3

Fixes some bugs, added capability to save to FILENAME, where FILENAME is the word you used for the search or the first word in you search string. Added some more messages just for fun. Defined colours as vars to make the code human readable.

Have fun :)

Cheers
Puppy Linux Blog - contact me for access

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#5 Post by 01micko »

v-0.4

Now a .pet!

Added -f option which calls the "find" command, very basic usage though, but it does find files.

Made the colours into an rc file which installs to /etc. This is great for any shell script, though different versions, the colours might be slightly different.

Reference http://edoceo.com/liber/linux-bash-shell

Enjoy!
Puppy Linux Blog - contact me for access

User avatar
Béèm
Posts: 11763
Joined: Wed 22 Nov 2006, 00:47
Location: Brussels IBM Thinkpad R40, 256MB, 20GB, WiFi ipw2100. Frugal Lin'N'Win

#6 Post by Béèm »

Nice.
I installed in lucid 208 and if I saw well, I should have gotten a menu entry in filesystem. Maybe I misinterpreted.
As it wasn't the case, I ran the script in a terminal.
With -f even a search with partial name can be done. (tried *fsck and got hits)
Note: the search argument is case sensitive. fsck isn't the same as Fsck.
Time savers:
Find packages in a snap and install using Puppy Package Manager (Menu).
[url=http://puppylinux.org/wikka/HomePage]Consult Wikka[/url]
Use peppyy's [url=http://wellminded.com/puppy/pupsearch.html]puppysearch[/url]

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#7 Post by 01micko »

Hi Béèm

No, no menu entry, this is purely command line stuff, :) . I think there is a small bug in PPM which reads certain pets as needing a menu entry when actually they do not. I will take a look at that.

Thanks for the comment, I should mention in the help (-h) that the wildcard (*) is handy, :wink: , especially for partial filenames.

Cheers
Puppy Linux Blog - contact me for access

User avatar
abushcrafter
Posts: 1418
Joined: Fri 30 Oct 2009, 16:57
Location: England
Contact:

#8 Post by abushcrafter »

Could you add the option of being able to search for part of a phase of a file/folder name or contents of a file(s) eg. phase="test" file name that has phase="testresultsofcommand".
[url=http://www.adobe.com/flashplatform/]adobe flash is rubbish![/url]
My Quote:"Humans are stupid, though some are clever but stupid." http://www.dependent.de/media/audio/mp3/System_Syn_Heres_to_You.zip http://www.systemsyn.com/

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#9 Post by 01micko »

hi abushcrafter

Well, you can do it with the wildcard "*".. do you think I should make that the default action? And say, add an option for an exact match?

BTW, the string and word options look for anything close, just you need to know where to look with those options. :wink:

Thanks for your interest

Cheers
Puppy Linux Blog - contact me for access

User avatar
abushcrafter
Posts: 1418
Joined: Fri 30 Oct 2009, 16:57
Location: England
Contact:

#10 Post by abushcrafter »

I know what I have done wrong. I thought it also searched file names as well as inside text files.
[url=http://www.adobe.com/flashplatform/]adobe flash is rubbish![/url]
My Quote:"Humans are stupid, though some are clever but stupid." http://www.dependent.de/media/audio/mp3/System_Syn_Heres_to_You.zip http://www.systemsyn.com/

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#11 Post by 01micko »

Hey abushcrafter... do you think the 'help' is clear enough? My diction is poor at the best of times!

Cheers
Puppy Linux Blog - contact me for access

User avatar
abushcrafter
Posts: 1418
Joined: Fri 30 Oct 2009, 16:57
Location: England
Contact:

#12 Post by abushcrafter »

01micko wrote:Hey abushcrafter... do you think the 'help' is clear enough? My diction is poor at the best of times!

Cheers
No it was me.
[url=http://www.adobe.com/flashplatform/]adobe flash is rubbish![/url]
My Quote:"Humans are stupid, though some are clever but stupid." http://www.dependent.de/media/audio/mp3/System_Syn_Heres_to_You.zip http://www.systemsyn.com/

gcmartin

SCLISS

#13 Post by gcmartin »

IFF I understand correctly, this is a search tool to "look" inside the files in the path for a particular word or phrase..

Is that correct?

Where I think there is confusion is as follows:
someone (noob like myself) could mistakenly assume that this tool could be used to list all files that have "text" in it filename.

If I understand correctly, this tool will open each file in a directory and look for a text/phase item within.

Is that correct? If so, maybe a simple statement that the tool cannot be used to list filenames which have 'text" in the filename.

Hope this helps.

Jasper

#14 Post by Jasper »

Hi,

I tried to use it without any success, but that is sure to be my lack of understanding and not a deficiency in the help.

I would very much appreciate a simple example (ideally using any actual directories and file(s) that come as standard with lupu 5.1) which I could copy and paste or type into my console to see some output.

Also, I don't have a middle mouse button and I find it tricky to simulate the paste process using the left and right buttons simultaneously; so I wonder is there, or could there be a shortcut or other action to paste to a terminal?

My regards

dinosoep
Posts: 28
Joined: Wed 18 Aug 2010, 09:59

#15 Post by dinosoep »

can come in handy, thanks
when my problem of not beeing able to install pets is fixed, I'll download it and try it out

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

Re: SCLISS

#16 Post by 01micko »

gcmartin wrote:IFF I understand correctly, this is a search tool to "look" inside the files in the path for a particular word or phrase..

Is that correct?

Where I think there is confusion is as follows:
someone (noob like myself) could mistakenly assume that this tool could be used to list all files that have "text" in it filename.

If I understand correctly, this tool will open each file in a directory and look for a text/phase item within.

Is that correct? If so, maybe a simple statement that the tool cannot be used to list filenames which have 'text" in the filename.

Hope this helps.
Thing is.. this is not a 'noob' tool at all, it's a development tool, it's not designed to be noob friendly.

It doesn't open any files. It scans files would be a closer description. See "man grep", that's what the word/string finding part is based upon.

Thanks for interest

Cheers
Puppy Linux Blog - contact me for access

User avatar
ttuuxxx
Posts: 11171
Joined: Sat 05 May 2007, 10:00
Location: Ontario Canada,Sydney Australia
Contact:

#17 Post by ttuuxxx »

Hi mick

The functions I would like to see is you select a folder with different files in it, and it searches for a text that you specify, then when its done it list
- which file it found it in.
- displays the line number
that would be perfect

and later on it might have a gui with open document next to search result, kind of like pfind.
ttuuxxx
http://audio.online-convert.com/ <-- excellent site
http://samples.mplayerhq.hu/A-codecs/ <-- Codec Test Files
http://html5games.com/ <-- excellent HTML5 games :)

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#18 Post by 01micko »

It already prints the file the text is found in :) (if you accept the "print to file" option it's easier to see that)

Line number would be cool, yes 8) , I'll look into that

Gui.. maybe one day :)

Cheers

EDIT: Ok ttuuxxx, added line numbers, see main post

1 person grabbed 0.5, it was wrong, please try again, sorry
Puppy Linux Blog - contact me for access

User avatar
ttuuxxx
Posts: 11171
Joined: Sat 05 May 2007, 10:00
Location: Ontario Canada,Sydney Australia
Contact:

#19 Post by ttuuxxx »

Works like a dream mick, excellent work :)
hmmm maybe a simple gui with a gtk search dialog, and a input text box for file names and a rox right click with 'search for text', so all you would have to do is right click on a folder or document and the gui would open with location already included and all you would have to do is type a name:) how easy would that be :) and then an option to save the text file.
Heck might as well have an option to open it with the default text editor. That would be cool :)
ttuuxxx
http://audio.online-convert.com/ <-- excellent site
http://samples.mplayerhq.hu/A-codecs/ <-- Codec Test Files
http://html5games.com/ <-- excellent HTML5 games :)

Post Reply