Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Versioning up a file with initials? Post 303035267 by RudiC on Saturday 18th of May 2019 02:55:49 AM
Old 05-18-2019
Not sure where the problem is:
Code:
printf '%sv%04d%s.%s' "$base" "$num" "$initials" "$ext"
 098_FGT_550_comp_v0002gp.nk

Your three digit version number has become four digit with your printf format.


Or, why not (provided you have a recent bash or ksh)



Code:
IFS="v."
ARR=( $file )
echo cp "$file" "$(printf '%sv%04d%s.%s\n' "${ARR[0]}" "$((10#${ARR[1]%%[^0-9]*} + 1))" "${ARR[1]##*[0-9]}" ${ARR[-1]})"
cp 098_FGT_550_comp_v002gp.nk 098_FGT_550_comp_v0003gp.nk


Last edited by RudiC; 05-18-2019 at 05:57 AM..
 

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
Devel::Refcount(3pm)					User Contributed Perl Documentation				      Devel::Refcount(3pm)

NAME
"Devel::Refcount" - obtain the REFCNT value of a referent SYNOPSIS
use Devel::Refcount qw( refcount ); my $anon = []; print "Anon ARRAY $anon has " . refcount($anon) . " reference "; my $otherref = $anon; print "Anon ARRAY $anon now has " . refcount($anon) . " references "; DESCRIPTION
This module provides a single function which obtains the reference count of the object being pointed to by the passed reference value. FUNCTIONS
$count = refcount($ref) Returns the reference count of the object being pointed to by $ref. COMPARISON WITH SvREFCNT This function differs from "Devel::Peek::SvREFCNT" in that SvREFCNT() gives the reference count of the SV object itself that it is passed, whereas refcount() gives the count of the object being pointed to. This allows it to give the count of any referent (i.e. ARRAY, HASH, CODE, GLOB and Regexp types) as well. Consider the following example program: use Devel::Peek qw( SvREFCNT ); use Devel::Refcount qw( refcount ); sub printcount { my $name = shift; printf "%30s has SvREFCNT=%d, refcount=%d ", $name, SvREFCNT($_[0]), refcount($_[0]); } my $var = []; printcount 'Initially, $var', $var; my $othervar = $var; printcount 'Before CODE ref, $var', $var; printcount '$othervar', $othervar; my $code = sub { undef $var }; printcount 'After CODE ref, $var', $var; printcount '$othervar', $othervar; This produces the output Initially, $var has SvREFCNT=1, refcount=1 Before CODE ref, $var has SvREFCNT=1, refcount=2 $othervar has SvREFCNT=1, refcount=2 After CODE ref, $var has SvREFCNT=2, refcount=2 $othervar has SvREFCNT=1, refcount=2 Here, we see that SvREFCNT() counts the number of references to the SV object passed in as the scalar value - the $var or $othervar respectively, whereas refcount() counts the number of reference values that point to the referent object - the anonymous ARRAY in this case. Before the CODE reference is constructed, both $var and $othervar have SvREFCNT() of 1, as they exist only in the current lexical pad. The anonymous ARRAY has a refcount() of 2, because both $var and $othervar store a reference to it. After the CODE reference is constructed, the $var variable now has an SvREFCNT() of 2, because it also appears in the lexical pad for the new anonymous CODE block. PURE-PERL FALLBACK An XS implementation of this function is provided, and is used by default. If the XS library cannot be loaded, a fallback implementation in pure perl using the "B" module is used instead. This will behave identically, but is much slower. Rate pp xs pp 225985/s -- -66% xs 669570/s 196% -- SEE ALSO
o Test::Refcount - assert reference counts on objects AUTHOR
Paul Evans <leonerd@leonerd.org.uk> perl v5.14.2 2011-11-15 Devel::Refcount(3pm)
All times are GMT -4. The time now is 06:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy