$ pwd ; get the present working directory
$ echo ~ ; get user's home directory
$ echo $HOME ; same as previous
$ sudo updatedb ; prep for following command. Note the user password will be requested when this command is executed.
$ locate ui. ; search the databases for a supplied but partial
;.......................................................... path/filename.ext "pattern" match, Like
l.......................................................... FindString() done externally. Need to capture
;.......................................................... the StdOut from this program and parse it into
;.......................................................... an array line by line.
$ locate > tmp.file; cat tmp.file ; allow for a piped call in RunProgram()
This is a slightly tricky one. I'm conducting two different grep searches of existing files, one to find "purebasic". the other to find "pb", combine them into tmp.1, then using sort on tmp.1 to reorganize the lines sequentially and write these to tmp.2, then using awk to out duplicate lines from tmp.2 and copying the rest back to tmp.1. Then using a combined cat tmp.1 | less command so that I can screen the results.
At this point I could add a step to screen out the binary files as well, but I chose not to. A little bit of study on what's where might be useful in the future.
Code: Select all
grep -riHn purebasic --include="*.pb*" --include="*.txt" --include="*.chm" > tmp.1; grep -riHn pb --include="*.pb*" --include="*.txt" --include="*.chm" --include="&.pbf" >> tmp.1; sort -n tmp.1 > tmp.2; awk '!x[$0]++' tmp.2 > tmp.1; rm tmp.2; cat tmp.1 | less
A question comes to mind, is that every time you open a terminal window, you start off as user and have to use some variation of the su or sudo command to become super user, which requires a password entry. Could that be faked? Could you pass the password to the use of "sudo -i" or "sudo -su", or to the first occurance of "sudo in a command? And would it carry forward to the use of additional sudo commands while running the same program, so you don't have to keep entering your password over and over as you go through steps that might be best done in a script file?
You can certainly generate a script file, which is just a text-based file, and then to a "chmod +x filename" to make it executable, then execute it via the RunProgram() option. but how persistent is that RunProgram() with respect to sudo?
And there is the shell itself. Maybe you want to preceed "find" with "sudo find", and maybe for a different command you want a specific shell like /bin/bash, so you might want to do "/bin/bash echo" rather than default to doing "[/bin/sh] echo" or vice versa.
Should you just do "sudo" or "/bin/bash" as the filename and pass the rest as a command line argument? I was getting "Finished" remarks from the compiler as I tried different things, but getting no results, except for a quick flash as a message came up and went away.. Take the same line and run it in a terminal window, and I got results.