Linux rename regex [duplicate] - regex

This question already has answers here:
Batch rename files
(9 answers)
Closed 7 years ago.
I want to rename name of files test123..-1.in, test123..-2.in, etc. to test123.in.
I tried commands:
rename -/d.in .in *.in, and many of similar but no one works(Can You explain why?).
Then i tried rename 's/.[0-9]*.in$/.in/' *.in, with same result..
Any proposition how to solve this problem in the simple way? I dont wanna write it mannualy.
Thanks for Your help.

You can use this rename:
rename 's/\.+-\d+\././' test123..-*in
or as per OP's comment below:
rename 's/-\d+\.in/.in/' *.in

Related

I am trying to get this Arrayformula to work [duplicate]

This question already has answers here:
Perform calculation only if both cells are not blank with arrayformula? [duplicate]
(3 answers)
ArrayFormula and "AND" Formula in Google Sheets
(4 answers)
Closed 4 months ago.
So I am trying to get this Arrayformula to work so I can plot this formula instead of calculating every Y myself.
=arrayformula(Sum(IF(Z3:Z294>Y$1;IFS(AB3:AB294>0;0;Z3:Z294>Y$1;Y3:Y294-(F3:F294*Y$1));0)-(Sum(IF(and(J3:J294>0;Z3:Z294>Y$1);F3:F294;0)))))
It gives me the (correct) return of this part:
Sum(IF(Z3:Z294>Y$1;IFS(AB3:AB294>0;0;Z3:Z294>Y$1;Y3:Y294-(F3:F294*Y$1));0)
But it doesn't subtract the second part:
-(Sum(IF(and(J3:J294>0;Z3:Z294>Y$1);F3:F294;0)))))
I am quite new to extensive Excel/Sheets formulas so I have no idea how to get this to work, It is also quite weird that the second part doesn't add up even seperate from the first part. So this also doesn't work:
=arrayformula(Sum(IF(and(J3:J294>0;Z3:Z294>Y$1);F3:F294;0)))
I hope it makes some sense without any context, thanks in advance!
Have a great rest of your day,
P.S. Please ignore simple mistakes, I don't code that often in Sheets ;)
AND is not supported. instead of
and(J3:J294>0;Z3:Z294>Y$1)
do this:
(J3:J294>0)*(Z3:Z294>Y$1)

take each line of a list and create one long single lined string wrapped by speechmarks [duplicate]

This question already has answers here:
How to edit all lines in Visual Studio Code
(9 answers)
Closed 3 years ago.
So essentially someone on our dev team made a bit of a big issue where they had changed all of the build actions on .csproj files and we are thinking of the easiest way to change them back.
We want to use regex to open all the csproj files via VSCode. The format to open multiple files in file explorer is
"filename" "filename1" "filename2"
my list is
com.Console.job1.csproj
com.Console.job2.csproj
com.Console.job3.csproj
com.Console.job4.csproj
my current regex
(.+)\n
then my regex to replace is
"$1"\s
which doesnt work at all
You can use this regex :
To locate pattern
([^\s]+)(\n)?
To replace :
"$1"
keep in mind the replace pattern contains a space at its end
Demo :
Here

How to write Reg Expression to Ignore a file path [duplicate]

This question already has answers here:
What special characters must be escaped in regular expressions?
(13 answers)
Closed 5 years ago.
I 've a File structure "solution/"
Need a reg exp to match all the files under "solution/" Excluding .img files in the path "solution/tree/changes/sample.img"
I tried below it but of not worked
^solution\/tree\/changes\/((?!.img).)*$
Thanks in advance
You did not mention language, but this should work
^solution\/tree\/changes\/(?!.*\.img).*$
see regex101 demo: https://regex101.com/r/Y7znBy/1
Important! You need to set multilineflag
#Fallenhero My Exact requirement is I 've following file structure
solution/moon/
solution/tree/anomoly/
solution/tree/enquiry/
solution/tree/changes/space.img
solution/tree/changes/mine.txt
I've to parse a json file as input with regular expression to copy all the files in the above structure except solution/tree/changes/space.img
JSON Input which I've tried but didn't work
"^solution\/(?!tree\/).*\/*",
"^solution\/tree\/(?!changes\/).*\/*",
"^solution\/tree\/changes\/((?!.img).)*$"
Could you please provide your ideas

How to create files in %appdata% with c++ [duplicate]

This question already has answers here:
How to open a folder in %appdata% with C++?
(6 answers)
Closed 6 years ago.
I need help creating a Folder in AppData.
Lets say I want to create a Folder in %appdata% called "MyFolder", which has the text file test.txt
I tried to use <fstream> and do this;
ofstream file("%appdata%\MyFolder\test.txt");
but it didn't work..
Things like %appdata% are OS specific, and Standard C++ has no direct means of dealing with them. You will have to write code to parse the file path, and extract values like %appdata% from the environment, or alternatively use non-standard functions to open the file, should such exist.
P.S. It also wouldn't work because "\" escapes the quotes, do "\\" instead.

Ignoring a particular file pattern in git [duplicate]

This question already has answers here:
Extended regular expressions (ERE) for .gitignore
(2 answers)
Closed 8 years ago.
I am using git in my project. My home directory contain few files like
Title v2.12.12.exe
Title v1.4.21.exe
Title v3.42.11.exe
All these starts with Title v and ends with .exe and contains some version in the middle. What changed should I made in .gitignore to ignore these types of file?
Just tried it and the simplest seem to work:
Title v*.exe
The only caveat is that you may catch more than expected like "Title v-not.a.valid.version.exe"