How do I represent a variable that will be a file name in a script?
On Mon, 2007-12-24 at 15:39 -0500, John Toliver wrote:
> Hello, > > I'm not very good at scripting so I'm sorry if the description isn't > as clear as it could be but I am trying to write a nautilus script > for shredding a file. I want to be able to right click on the file I > wish to destroy, select "scripts>shred" and the script then knows to > act on this file. How do I represent a variable in Linux scripting? > I think it should be the equivalent of "%1" in batchfile scripting on > windows. Arguments on the commandline are $1 $2 ... for the first, second, ... word on the command line ($0 is the name of the program being run). Other variables can be defined by simply putting using the '=' operator, and references with the '$' operator: FOO=bar echo $FOO You can try this out in the Terminal directly. If you're making nautilus scripts, you should read up on the details (which are different from normal shell scripts): http://www.gnome.org/learn/users-guide/latest/gosnautilus-440.html http://www.linux.com/feature/114134 > Second, I wish I knew how to describe this better but what does the > terminal recognize as "operators" on files. In windows if I type: > "copy <sourcepath>f*.exe <destinationpathfoldername>" it will copy > all files starting with "f" that are executables to the path I > specified. what are the equivalents of operators like "*.*", the > vertical line "|" that goes before the "more" command in windows > terminal that splits output to a page at a time, and other such > commands. First what are these things called, secondly where can I go > to read about them? There are two sorts of tools to match multiple files (or multiple whatevers): globs and regexps. What you describe is the "glob," where you type in some part of a name and put '?' where you don't want any single character to be matched and '*' where you'd like any sequences of characters matched. This is what is done in the shell and in shell scripts. In addition to '*' and '?', you can also use '[' and ']' to match from a specific set of characters. For example [abc]* will match any name that starts with 'a', 'b', or 'c'. http://www.faqs.org/docs/abs/HTML/globbingref.html http://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html http://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html Other tools (such as perl, grep, sed, ...) use what is know as a "regexp" (REGular EXPression) which comes from theoretical computer science. Here you use '.', '?', '*', '[', '(' and some other operators to form more powerful matching words. I won't go into them here, but you can read up on them elsewhere. > -- > Patience yields far greater results than brute force or rage ever > could so relax......it's just life !!! -- Michael R. Head <burner@suppressingfire.org> http://picasaweb.google.com/demiri.head.wedding -- ubuntu-users mailing list ubuntu-users@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users |
How do I represent a variable that will be a file name in a script?
John Toliver wrote the following on 24.12.2007 21:39
> Hello, > > I'm not very good at scripting so I'm sorry if the description isn't as > clear as it could be but I am trying to write a nautilus script for > shredding a file. untested: http://www.gnome-look.org/content/show.php/shred_file?content=66603&PHPSESSID=452bdac0b9c0848 ca188113ddf19d8d1 </snip> -- Thilo key: 0x4A411E09 -- ubuntu-users mailing list ubuntu-users@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users |
| All times are GMT. The time now is 02:11 PM. |
VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.