Sponsored Content
Full Discussion: Rename file of special type
Top Forums Shell Programming and Scripting Rename file of special type Post 302776571 by Akshay Hegde on Wednesday 6th of March 2013 01:54:17 PM
Old 03-06-2013
Rename file of special type

HI ! all
till date I usually rename file like this

Code:
n=201108290000
for file in *.nc; do
    file_name=M.m.1.1.1.$n.ready
    n=$(( $n+1 ))
    mv $file $file_name
done

but in this case I have to rename file depending on basename of file, when I list files results like this, if there is leap year then also it should rename properly

Code:
S19972441997273.L3m_MO_CHL_chlor_a_9km.G3.nc
S19972741997304.L3m_MO_CHL_chlor_a_9km.G3.nc
S19973051997334.L3m_MO_CHL_chlor_a_9km.G3.nc
S19973351997365.L3m_MO_CHL_chlor_a_9km.G3.nc
S19980011998031.L3m_MO_CHL_chlor_a_9km.G3.nc
S19980321998059.L3m_MO_CHL_chlor_a_9km.G3.nc
S19980601998090.L3m_MO_CHL_chlor_a_9km.G3.nc
S19980911998120.L3m_MO_CHL_chlor_a_9km.G3.nc
S19981211998151.L3m_MO_CHL_chlor_a_9km.G3.nc
S19981521998181.L3m_MO_CHL_chlor_a_9km.G3.nc
S19981821998212.L3m_MO_CHL_chlor_a_9km.G3.nc
S19982131998243.L3m_MO_CHL_chlor_a_9km.G3.nc
S19982441998273.L3m_MO_CHL_chlor_a_9km.G3.nc
S19982741998304.L3m_MO_CHL_chlor_a_9km.G3.nc
S19983051998334.L3m_MO_CHL_chlor_a_9km.G3.nc
S19983351998365.L3m_MO_CHL_chlor_a_9km.G3.nc

expecting output like this

Code:
September_1997.nc
October_1997.nc
November_1997.nc
December_1997.nc
January_1998.nc
February_1998.nc
March_1998.nc
April_1998.nc
May_1998.nc
June_1998.nc
July_1998.nc
August_1998.nc
September_1998.nc
October_1998.nc
November_1998.nc
Decembe_1998.nc

and after renaming I want to sort files in ascending order.
 

9 More Discussions You Might Find Interesting

1. Programming

file type

Hi Everyone! I am working on a c program which displays all the directories and files under each directory. I want to know what kind of file each is. Like, is the file an ascii text file or english text or a c file. if it is an executable, is it an binary file or a shell script. I was told to... (12 Replies)
Discussion started by: vijlak
12 Replies

2. Shell Programming and Scripting

String type to date type

Can one string type variable changed into the date type variable. (1 Reply)
Discussion started by: rinku
1 Replies

3. Programming

array type has incomplete element type

Dear colleagues, One of my friend have a problem with c code. While compiling a c program it displays a message like "array type has incomplete element type". Any body can provide a solution for it. Jaganadh.G (1 Reply)
Discussion started by: jaganadh
1 Replies

4. UNIX for Dummies Questions & Answers

rename more files special case

hello all i have a big problems for me if i have more files as example test.ghrt.part01.rar test.ghrt.part02.rar test.ghrt.part03.rar test.ghrt.part04.rar test.ghrt.part05.rar test.ghrt.part06.rar test.ghrt.part07.rar test.ghrt.part08.rar test.ghrt.part09.rar test.ghrt.part10.rar... (13 Replies)
Discussion started by: ateya
13 Replies

5. Shell Programming and Scripting

How to know the file type

Hi I am doing some operation in which files will be dumped in Specific location. I want to know the File type.i.e i am expecting CSV files. So i want to write a script so that i can check the file which are dumped are in CSV Files.xxxx.csv format. (2 Replies)
Discussion started by: Aditya.Gurgaon
2 Replies

6. Shell Programming and Scripting

Rename files and directories with special characters

Hello guys, I was looking for a shell script that removes all the special characters from the files and the subdirectories recursively. I could not locate it any more. Dose any body have a similar script that dose that? Thanks for the help. AV (0 Replies)
Discussion started by: avatar_007
0 Replies

7. Shell Programming and Scripting

[solved] File type error (not a regular file)

Hi friend, i have written script as below to check the file existance. but i got error path="/k/p1100/users/jewel/Output" FILENAME=`ls -lrt $path/*HT|tail -1|cut -d "/" -f 8` if ; then echo "$FILENAME is available " chmod 755 $path/$FILENAME /usr/bin/scp... (0 Replies)
Discussion started by: Jewel
0 Replies

8. Shell Programming and Scripting

Shell script to read file and check file type

Hi, I have a file with few values in it. I need script help to read file line by line and check: 1/if it's a file (with extension eg .java .css .jar etc ) or 2/if it's a file without extension and treat it as a directory and then check if the directory exists in working copy else create one... (6 Replies)
Discussion started by: iaav
6 Replies

9. UNIX for Beginners Questions & Answers

Rename File Name with Special Characters

I am trying to rename files with spaces and other characters and not able to be successful. FileNames: UPLOAD REFERENCE.xls UPLOAD MASS REFERENCE.XLS find /UPLOAD REFERENCE/ -depth -type f -name "* *" -exec rename " " "_" "{}" ";" The above one is successful to replace spaces... (1 Reply)
Discussion started by: eskay
1 Replies
Locale::Codes::LangVar(3pm)				 Perl Programmers Reference Guide			       Locale::Codes::LangVar(3pm)

NAME
Locale::Codes::LangVar - standard codes for language variation identification SYNOPSIS
use Locale::Codes::LangVar; $lvar = code2langvar('acm'); # $lvar gets 'Mesopotamian Arabic' $code = langvar2code('Mesopotamian Arabic'); # $code gets 'acm' @codes = all_langvar_codes(); @names = all_langvar_names(); DESCRIPTION
The "Locale::Codes::LangVar" module provides access to standard codes used for identifying language variations, such as those as defined in the IANA language registry. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default IANA language registry codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language variations. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lvar = code2langvar('en','alpha-2'); $lvar = code2langvar('en',LOCALE_CODE_ALPHA_2); The codesets currently supported are: alpha This is the set of alphanumeric codes from the IANA language registry, such as 'arevela' for Eastern Armenian. This code set is identified with the symbol "LOCALE_LANGVAR_ALPHA". This is the default code set. ROUTINES
code2langvar ( CODE [,CODESET] ) langvar2code ( NAME [,CODESET] ) langvar_code2code ( CODE ,CODESET ,CODESET2 ) all_langvar_codes ( [CODESET] ) all_langvar_names ( [CODESET] ) Locale::Codes::LangVar::rename_langvar ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangVar::add_langvar ( CODE ,NAME [,CODESET] ) Locale::Codes::LangVar::delete_langvar ( CODE [,CODESET] ) Locale::Codes::LangVar::add_langvar_alias ( NAME ,NEW_NAME ) Locale::Codes::LangVar::delete_langvar_alias ( NAME ) Locale::Codes::LangVar::rename_langvar_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangVar::add_langvar_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangVar::delete_langvar_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.iana.org/assignments/language-subtag-registry The IANA language subtag registry. AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2012 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.2 2012-10-11 Locale::Codes::LangVar(3pm)
All times are GMT -4. The time now is 11:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy