Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Versioning up a file with initials? Post 303035260 by scribling on Friday 17th of May 2019 07:43:33 PM
Old 05-17-2019
Versioning up a file with initials?

I have this code that works great ...

Code:
#!/bin/sh

for file in "$@"
do
        ext=${file##*.}
        base=${file%.*}
        num=${base##*v}
        zeroes=${num%%[!0]*}
        num=${num#$zeroes}      #remove leading zeros, or it uses octal
        num=$((num+1))
        base=${base%v*}
        new=$(printf '%sv%04d.%s' "$base" "$num" "$ext")
        cp -nv "$file" "$new"
done

Now I need it to work with a file that has two characters after the version number.
098_FGT_550_comp_v002gp.nk

I've tried just about everything I know to get this to work but it seems the characters get picked up as part of the number.

Any help is appreciated.

Thank you.
 

9 More Discussions You Might Find Interesting

1. Solaris

Solaris versioning

Please correct me if I am wrong... Isnt the only difference between minor releases of Solaris, ex. 9/04 and 9/05, is the patche revs between them? If so, why does the /etc/release info stay static when patched? (4 Replies)
Discussion started by: mhm4
4 Replies

2. Programming

binary versioning

Dear Members, Do you know any information about versioning a binary file. That means test.out 1.0.0, 1.0.1, 1.1.0, and so on. Can I manually edit version number (both major and minor) and revision number myself (how?) or any utility to set version number (which one?). Best Regards, Francesco (2 Replies)
Discussion started by: francescoandrio
2 Replies

3. Linux

Any Filesystems in Linux Support Versioning?

A question that has come up repeatedly where I work from our former VMS guys is... "will any Linux filesystem ever support versioning like RMS did"? When they talk about versioning they really are talking about something that *I think* would involve having apps that support versioning. For... (7 Replies)
Discussion started by: deckard
7 Replies

4. Shell Programming and Scripting

File Versioning with Shell Script

Need to add the version date to the moved file if same file name in folder exists and limit the same files in the folder. Ex: If moved or copy file abc.txt to folder XYZ then append the version date abc07112011.txt or abc07122011.txt in the folder. \xyz abc07132011.txt abc07122011.txt... (2 Replies)
Discussion started by: Brado
2 Replies

5. Shell Programming and Scripting

Initials of a name

I'm stuck, so please tell me how to print the initials of a name (for ex E C for Eric Cartman). If you could suggest a website related to string handling then that would be much appreciated too. Thanks! (3 Replies)
Discussion started by: deepwoodsv
3 Replies

6. SCO

Versioning through undelete

Hi , I am using SCO openserver realease 3.2 and tried to test versioning on a directory with undelete -s . The command executes well but it is not creating any versions of the files in it. I have also setted versioning options via filesystem and then remounted it but of ... (0 Replies)
Discussion started by: dextergenious
0 Replies

7. Programming

Execution problem with Libtool Versioning control

Hi, Is anybody familiar with libtool could explain me the following issue.? I've created a small factorial program(fact_impl.c, fact_appln.c & fact.h) in order to know about this libtool. >>> fact.h #include<stdio.h> #include<math.h> extern unsigned int fact_num(unsigned int num);... (0 Replies)
Discussion started by: Parameswaran
0 Replies

8. UNIX for Dummies Questions & Answers

Find a file with common initials and last words

Hi, I have a requirement like i have to find out files and remove them on a daily basis. The files are generated as abc_jnfn_201404230004.csv abc_jnfo_201404230004.csv abc_jnfp_201404230004.csv abc_jnfq_201404230004.csv abd_jnfn_201404220004.csv abe_jnfn_201404220004.csv i want to... (1 Reply)
Discussion started by: Mohammed_Tabish
1 Replies

9. Shell Programming and Scripting

Need to get versioning of the branch name dynamically

Hi, I need to get versioning of the branch name dynamically. can you please help us to achieve this functionality. curl https://altrecmktg.com/artifactory/mediamarketing/release-2.0.1/altrec.tar curl https://altrecmktg.com/artifactory/mediamarketing/release-2.0.2/altrec.tar everytime... (5 Replies)
Discussion started by: lkeswar
5 Replies
AptPkg::Version(3pm)					User Contributed Perl Documentation				      AptPkg::Version(3pm)

NAME
AptPkg::Version - APT package versioning class SYNOPSIS
use AptPkg::Version; DESCRIPTION
The AptPkg::Version module provides an interface to APT's package version handling. AptPkg::Version The AptPkg::Version package implements the APT pkgVersioningSystem class. An instance of the AptPkg::Version class may be fetched using the "versioning" method from an AptPkg::System object. The following methods are implemented: label Return the description of the versioning system, for example: Standard .deb for Debian systems. compare(A, B) Compare package version A with B, returning a negative value if A is an earlier version than B, zero if the same or a positive value if A is later. rel_compare(A, B) Compare distribution release numbers. check_dep(PKG, OP, DEP) Check that the package version PKG satisfies the relation OP to the dependency version DEP. The relation OP is specified in the Debian syntax regardless of the versioning system: << strictly earlier <= earlier or equal = exactly equal >= later or equal >> strictly later upstream(VER) Return the upstream component of the given version string. SEE ALSO
AptPkg::Config(3pm), AptPkg::System(3pm), AptPkg(3pm). AUTHOR
Brendan O'Dea <bod@debian.org> perl v5.14.2 2012-03-16 AptPkg::Version(3pm)
All times are GMT -4. The time now is 10:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy