Tag Info

New answers tagged

0

You can do it like this: cd -P files_input/.. && mkdir files_output && pax -rws'|.*/\(.*\)/\(.*\)|\1.\2|' \ files_input/??-2015/index.html files_output Which will glob all index.html files in folders in child directories of ./files_input named with two characters, then a dash, then the string 2015 and copy all of those files into ...


4

mv either renames a single file or moves many files into a single directory. If you want to rename many files you probably want to use rename. Depending on your version of rename you do: rename .1.gz.html .html *.1.gz.html or rename 's/\.1\.gz\.html/\.html/' *.1.gz.html The first version is a bit easier to write the second one is more powerful and ...


1

A wildcard like that gets expanded into everything that matches it before the mv command even runs. Making matters worse is that *.html will also match your *.1.gz.html files. This means that (for example two files named abc.1.gz.html and def.1.gz.html) your command above is essentially running: mv abc.1.gz.html def.1.gz.html abc.1.gz.html def.1.gz.html ...


0

Try removing the quotes around {}, as seemed to work for me that way. $ find foo* files_output -ls 27002 0 drwxrwxr-x 2 steve steve 60 Jul 2 15:04 foo1 25373 0 -rw-rw-r-- 1 steve steve 0 Jul 2 15:04 foo1/index.html 27003 0 drwxrwxr-x 2 steve steve 60 Jul 2 15:04 foo2 25374 0 -rw-rw-r-- 1 steve ...


0

Actually found out the reason it wasn't working is because in the machine I'm working there is a weird version of rename whose syntax is actually rename from to files*. Hadn't seen that one before.


0

Hm, the line mv "$WEBROOT/web-template-folder" $WEBROOT/$website_name" should be mv "$WEBROOT/web-template-folder" "$WEBROOT/$website_name" (mind the double quotes)


5

I got intrigued myself and did a little digging. At first I thought that's some kind of a side effect, e.g. the node gets 2 links and then the original link is deleted and ctime is more of an accident than a deliberate action. In case it is unclear for someone, the file is represented by an inode which has nothing to do with the name. The inode "knows" how ...


2

A long, long time ago, the command mv oldpath newpath was implemented inside mv.c as link(oldpath, newpath); unlink(newpath); Now we have a system call rename(oldpath, newpath); but apparently it still works the same way, inside the kernel.  This is a conjecture on my part, but it’s based on the fact that one of the failure modes for rename(2) is ...


4

At least three different utilities imaginatively named rename(1) are floating around in the Linux waters: (1) the one that came with util-linux, (2) an older Perl script by Larry Wall further munged by Tom Christiansen, and (3) a newer Perl script evolved from the former and included with Unicode::Tussle. As far as I can tell, what you want can't be done ...


2

If (and this is a big if) you are using the rename that uses a perl expression to modify filenames you can achieve what I think you want like this: rename 's/(\d+)/"a" x $1/e' * The e flag is explained in perldoc perlre. It modifies the interpretation of right hand side so that it is evaluated as a perl expresssion.


0

The reason the filename gets doubled is that if $fname is [test], then name="${fname%\.*}" extension="${fname#$name}" results in: name=[test] extension=[test] (Explanation below.) Later, when $extension is concatenated to $newname, you'll get test][test]. What you should have used: name=${fname%.*} extension=${fname#"$name"} The quotes around the ...


0

It's even simpler with rename embedded in a two-liner: while rename ] '' *; do true; done while rename [ '' *; do true; done rename replaces the first occurrence of $1 with $2 in filename(s) in $3+ and this block removes any and all brackets in all file-and-directorynames in CWD.


1

Solution posted by @juicebyah will only remove the initial bracket. If OP wants to remove both brackets, it is better to use sed in this way: find . -type f -iname "*[*" | \ while IFS= read -r line; \ do mv "$line" "$(printf %s "$line" | sed -re 's/(\[|\])//g')"; done;


2

i found this one liner and this work : for x in *[*; do mv -- "$x" "${x//[/}"; done this should do the job , just replace left or right bracket each time yu execute this commandl



Top 50 recent answers are included