I tried a simple Nautilus script that redirected NAUTILUS_SCRIPT_SELECTED_FILE_PATHS to a text file, and I encountered the same issue as you describe when running the script on a file in what you...
Type: Posts; User: kaibob; Keyword(s):
I tried a simple Nautilus script that redirected NAUTILUS_SCRIPT_SELECTED_FILE_PATHS to a text file, and I encountered the same issue as you describe when running the script on a file in what you...
I'm just learning Python and thought I would suggest an approach that is only slightly different from that suggested by LemursDontExist. I have omitted the blank line in the output as that is what...
The shell script was mine and was written when I was first learning shell scripts. The script was wrong in two respects, and I have deleted it. Thanks for the heads-up.
Deleted post.
The following will do what you want. If the source file is large, I suspect this is better done with sed or awk. Perhaps another forum member will be able to help if that is the case.
...
Gmargo has already answered your question, but I thought I would mention one item. Your list of files contains a directory, and because of that gmargo's first solution may not work as you want. This...
By globs, I assume you are referring to the nullglob and dotglob shell options.
Nullglob is needed because the "files" array variable will otherwise contain *.avi and *.mkv if no matching files...
deleted
You my want to consider using an array to count files in a directory. This will work with bash only.
http://mywiki.wooledge.org/BashFAQ/004
I came across the following command-line a while back. It produces eight random upper- and lower-case letters.
tr -dc "[:alpha:]" < /dev/urandom | head -c 8
By starting your script with #!/bin/sh, you are using the dash shell, which does not support arrays. That is the reason for the error message. You do not receive the error message in a terminal...
sh228 has covered the most important points on this issue, but the following contains a little additional information:
http://mywiki.wooledge.org/BashFAQ/082
That looks good. I have included below the shell script as I would write it, but this is more a matter of style and preference than right or wrong. Also, my Bash skills are only middling, so there...
I tested the shell script and it seems to work fine. So, my comments are mostly items to consider.
* Indent the script for improved readability. There are many guides on this topic--the first...
I do not know perl and cannot fully answer your question. Perhaps with this bump, another forum member will see this thread and be of help.
For practice, I decided to write this as a bash shell...
The OP has marked this thread as solved, but I wanted to use it as a learning aid to work on certain bash skills and thought I would post my final shell script.
#!/bin/bash
while true ; do...
I think this will do what you want. The find commands finds all files in the source directory and subdirectories. The sort command randomizes the list of files. The mapfile command creates an array...
This whole issue is discussed under item 4 on the following page:
http://mywiki.wooledge.org/BashPitfalls?highlight=%28\bCategoryShell\b%29
It generally recommends that the x$var solution be...
The Greg's Wiki site has an informative FAQ on this topic:
http://mywiki.wooledge.org/BashFAQ/026
On my computer, user-selected files are processed by a Nautilus script in the order that they are shown in the right pane of the Nautilus file browser. This order can, of course, be changed by...
You can use parameter expansion as explained in the Bash Reference Manual:
http://www.gnu.org/software/bash/manual/bashref.html#Shell-Parameter-Expansion
This same topic is discussed under...
Like TeoBigusGeekus, I tried your script and it works fine with bash. It does not work with dash (/bin/sh) which does not support arrays or ((...)). For more information:
...
The trouble with [0-9]* is that it allows a number followed by one or more characters that are not numbers, which breaks the script. This is pretty unlikely, so I guess it's not important. Thanks...
Thanks for the information--it explains things.
I did manage to get the script working as I want using regular pattern matching. The input from the user is one or two digits, so I used:
...
It's a bit confusing, but it appears that the dog directory contains a space at the end. If that's the case, then you have a few options. One is to change into the dog directory before renaming so...