SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Looks ok to me. But the only real way to be confident it works is to test it. You could use the File::Find module in Perl (I'm sure there's more than one way to do it with Perl). Depends on whether you're only doing it this once, or if you want to write a generally applicable, robust and reusable script.
What are the brackets {} for? I don't think you need it for sed. Some obscure 'find' syntax? I hate the way you have to add the escaped ';' for an -exec.
What are the brackets {} for? I don't think you need it for sed. Some obscure 'find' syntax? I hate the way you have to add the escaped ';' for an -exec.
"{}" signifies "arguments" passed to -exec command.
2 Perl *so called help* (my cheat sheet(s) if you please) perl scripts. 1 is named clplh (command line perl help) the other is named findh
Since these are made for me to run them from the commandline (and they merely print to STDOUT) it *is* possible that some item(s) are escaped in these scripts so that when they are run that they print correctly (in konsole, I just copy/paste so as to end up with the specific command that I want.
Scripts (not konsole or console output) follow next:
via commandline, runs that command, replaces string with
stringier using g global and i insensitive options.
Operates on all .html files in a folder (CWD) also makes
a backup of each file prior to the operation.
STUFF
al@AB60R:~/bin$
al@AB60R:~/bin$
al@AB60R:~/bin$ cat findh
#!/usr/bin/perl
# findh prints example find useage
print "\nfilename accepts wildcards || Or try: locate filename\ncmd | top dir (recurses down) | opt -n denotes-> | name_of_file2find\n\n";
print "find /home -name filename\n--\n";
perl -MFile::Find -le 'find sub{print if /\\.txt\$/}, "."'
my \@files = `find $dir -name '*.txt'`;
# files only also in cur dir only
find . -name '*' -maxdepth 1 -type f > ~/myfiles.txt
find . -name '*.htm' -maxdepth 1 -type f > ~/myfiles.txt
# cp files to /tmp/slackupdate (ok prompts, exec just does it)
find . -type f -name "*.txt" -maxdepth 1 -ok cp {} /tmp/slackupdate \\;
find . -type f -name "*.txt" -maxdepth 1 -exec cp {} /tmp/slackupdate \\;
locate command. To upgrade the database for the locate command do this while in the superuser mode: slocate -u. Then wait a while while it upgrades. To use the command just type locate mozilla (for example) and it will post all of the mozilla references in your computer.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.