find

Rename files and directories recursively under ubuntu /bash

十年热恋 提交于 2020-01-19 02:35:05
问题 I want to rename all files and directories that contain the word "special" to "regular". It should maintain case sensitivity so "Special" won't become "regular". How can i do this in bash recursively? 回答1: Try doing this (require bash --version >= 4): shopt -s globstar rename -n 's/special/regular/' ** Remove the -n switch when your tests are OK There are other tools with the same name which may or may not be able to do this, so be careful. If you run the following command ( GNU ) $ file "$

Rename files and directories recursively under ubuntu /bash

自闭症网瘾萝莉.ら 提交于 2020-01-19 02:34:07
问题 I want to rename all files and directories that contain the word "special" to "regular". It should maintain case sensitivity so "Special" won't become "regular". How can i do this in bash recursively? 回答1: Try doing this (require bash --version >= 4): shopt -s globstar rename -n 's/special/regular/' ** Remove the -n switch when your tests are OK There are other tools with the same name which may or may not be able to do this, so be careful. If you run the following command ( GNU ) $ file "$

Using awk how do I print all lines containing duplicates of specific columns?

微笑、不失礼 提交于 2020-01-17 06:56:34
问题 Input: a;3;c;1 a;4;b;2 a;5;c;1 Output: a;3;c;1 a;5;c;1 Hence, all lines which have duplicates of columns 1,3 and 4 should be printed. 回答1: If a 2-pass approach is OK: $ awk -F';' '{key=$1 FS $3 FS $4} NR==FNR{cnt[key]++;next} cnt[key]>1' file file a;3;c;1 a;5;c;1 otherwise: $ awk -F';' ' { key=$1 FS $3 FS $4; a[key,++cnt[key]]=$0 } END { for (key in cnt) if (cnt[key] > 1) for (i=1; i<=cnt[key]; i++) print a[key,i] } ' file a;3;c;1 a;5;c;1 The output order of keys in that second script will be

Rails: using find method to access joined tables for polymorphic relationships

我与影子孤独终老i 提交于 2020-01-16 19:29:07
问题 Ok, I have a generic TimeSlot model that deals with a start_at and an end_at for time spans. A couple models derive from this but I'm referring to one in this question: AppointmentBlock which is a collection of Appointments . I want to validate an AppointmentBlock such that no other AppointmentBlocks have been scheduled for a particular Employee in the same time frame. Since AppointmentBlock has a polymorphic association with TimeSlot , you have to access the AppointmentBlock 's start_at and

Perl File::Find::Rule to find latest file in directories

余生颓废 提交于 2020-01-16 04:14:06
问题 I am trying to get the list of latest files in each dir(for each project) under a specific path ( $output ) , excluding a single dir OLD use strict; use warnings; use Data::Dump; use File::Find::Rule; my $output = "/abc/def/ghi"; my @exclude_dirs = qw(OLD); my $rule = File::Find::Rule->new; $rule->or($rule->new ->file() ->name(@exclude_dirs) ->prune ->discard, $rule->new); my @files = $rule->in("$output"); dd \@files; My Dir Structure: My Dir Structure: /abc/def/ghi ├── project1 │ ├── 2013 |

Find and Replace a section of a string with wildcard type search

岁酱吖の 提交于 2020-01-15 12:47:09
问题 I want to be able to read a file, and replace all instances of: M9S1800.2 with S1800 (I want to get rid of the M9 and the .2). The problem I am having is that the 4 digit number after the "S" can be different every time, as well as the number after the decimal. For example, It can be: M9S3200.1 or M9S5400.1 or M9S5400.2 Can someone please show me how to do this with C#? I know how to find and replace by using this code: StreamReader reader = new StreamReader(fDialog.FileName.ToString());

List<T> Find method in C++/CLI

百般思念 提交于 2020-01-15 08:44:07
问题 Why it doesn't work in C++/CLI ? _list->Remove(_list->Find(x => x.Inode == 2)); I received an error error C2065: 'x' : undeclared identifier 回答1: @Hans Passant's comment is the answer, so I'm just pasting it here: C++/CLI doesn't support lambda expressions. The language was frozen in 2005, no new bells and whistles were added to it since then. You'll need to use a delegate explicitly. C++11 got lambdas but they are not compatible with C++/CLI. – Hans Passant 回答2: As Hans Passant commented, C+

cakephp having condition in find

元气小坏坏 提交于 2020-01-15 05:25:06
问题 can someone help me, and show me how to insert BEETWEN in having clausule in cakephp exampleo of my codE: $zaduzenja = $this->Zaduzenja->find('all',array( 'conditions' => array( 'Zaduzenja.placeno' => 0 ), 'fields' => array('Zaduzenja.obveznici_id', 'SUM(Zaduzenja.zaduzenje) as dug'), 'group' => 'Zaduzenja.obveznici_id HAVING array(dug BETWEEN ? AND ? => array('.$iznosOd,$iznosDo)' )); but this not working, i only want Calculated column "dug" to check if Dug >=$temp 1 AND Dug <=$temp2, but

find command in bash shell and the -name option doubts

时光总嘲笑我的痴心妄想 提交于 2020-01-14 18:56:52
问题 What is the difference between the two below: find . -type f -name \*.bmp find . -type f -name *.bmp I have tested,they both return the same result,so is there anything different _deep inside_ ? Added from the removed answer: So it is to avoid the shell expansion for the special ***** character,solely pass * as a argument to the find command and let it process it. But on my machine,they are all good, both return the bmp files in and below the current directory,to name a few,the result is like

find command in bash shell and the -name option doubts

这一生的挚爱 提交于 2020-01-14 18:56:22
问题 What is the difference between the two below: find . -type f -name \*.bmp find . -type f -name *.bmp I have tested,they both return the same result,so is there anything different _deep inside_ ? Added from the removed answer: So it is to avoid the shell expansion for the special ***** character,solely pass * as a argument to the find command and let it process it. But on my machine,they are all good, both return the bmp files in and below the current directory,to name a few,the result is like