I am using cygwin on Windows 7.
I am starting with a data file with filename "name_1.ext", like "20180831_snapgenotypes_1.csv".
The "_1" before ".ext" is a version number. Integers (0-99) are sufficient. They don't have to be like "1.0.0".
The filename may contain other "_" or "-" characters.
The filename might not have a version number, as in "name.ext" or "20180831_snapgenotypes.csv".
I want to leave the current filename and the contents of the file intact. I want to do something (or nothing) to the file contents and save the output to a new file of the same name but increment the version number by 1.
"name.ext" should become "name_1.ext".
"name_1.ext" should become "name_2.ext".
and so on.
I found this post "unix-for-dummies-questions-and-answers/228027-incrementing-new-file-version-number.html" and wrote:
This seems to work if my infile has a version number "_nn".
I tried to add a test whether the filename has this version number and, if not, name the outfile "name_1.ext". My echo statements are just for debugging:
My test
is not correct. It always evaluates to false.
There is an error from this line: [: missing `]'. I don't get that clue.
Hi,
Try to replace:
by (space is important) :
But, you must sort your file list, because if you rename file_1 to file_2 before file_2 to file_3, you will rename file_1 to file_3 and real file_2 will suppress.
Hi
I am unix newbie looking for a unix bash script that can make it easier to do my code work. we have a code number for each code block that we want to incrementally assign. We have 10000 of these and it is very laborious to do this one by one.
so what we want is start from the top of the... (4 Replies)
Two questions:
1) Is there a way to create a new column (i.e. ID) to an existing file containing data and the new column ID populate as an auto incrementing number?
for example:
(Current file has headers and is PIPE delimited.)
**data looks like this**
"COL1"|"COL2"|"COL3"|"COL4"|"COL5"... (4 Replies)
Two questions:
1) Is there a way to create a new column (i.e. ID) to an existing file containing data and the new column ID populate as an auto incrementing number?
for example:
(Current file has headers and is PIPE delimited.)
**data looks like this**
"COL1"|"COL2"|"COL3"|"COL4"|"COL5"... (0 Replies)
I have number in file which contains date and serial number:
2013101000.
The last two digits are serial number (00). So maximum of serial number is 100.
After reaching 100 it becomes 00 with incrementing 10 which is day with max 31.
after reaching 31 it becomes 00 and increments 10... (31 Replies)
Hello All,
In the below script i am trying to check and list the file names, get the last file with highest version number and then increment the version number when i create another file. Example: file1 is COBANK_v1.xml and file2 i want to put it as COBANK_v2.xml, to achieve this i am using awk... (15 Replies)
Hello,
Here's a file of mine:
key1:431
key2:159
key3:998
I need to change these keys to something bigger - and I actually need to shift them all by a range of 3.
The output would be:
key1:434
key2:162
key3:1001
I can't find the propper sed/awk line that would alter all my... (4 Replies)
I have the following code and getting the error
./raytrac.bash: line 231: ((: 0++: syntax error: operand expected (error token is "+")
iarg = 0
iarg=0
narg=$# # Number of arguments passed.
echo "narg = $narg"
argsArr=("$@") # Set... (1 Reply)
morning guys and gals,
I am haveing a problem, a friend helped me out with this script but i dont know how to add incrementing number for each movie in movie.list. this is what i have so far. any assistance would be great.
I have removed the GT and LT symbols so you can see what is going on... (5 Replies)
Hi
I wrote this script with the help of you guyz.My next challenge is to increment the port using single file.So far iam using this code to increment hp1 and hp2 .To increment port numbers, iam using two different files (.default_port_hp1 and .default_port_hp2).The challenge for me is to use... (0 Replies)