Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Rename file knowing the first 7 carachters Post 302179745 by ShawnMilo on Friday 28th of March 2008 11:33:32 AM
Old 03-28-2008
This will do most of it:

Code:
for F in $(\ls -1 PROVEDP_*); do echo $F; mv $F $(echo $F | perl -pe 's/^PROVEDP_(\w{3})_(\d{4}).*$/IN_PROV_$2$1.dat/'); done

It lists all files and then renames them. For example, it will rename PROVEDP_JAN_20080205 to IN_PROV_2008JAN.dat.

However, it doesn't convert JAN to 01, as in your example. You initially said the output needed to contain the "???" you retrieved from the beginning of the file, but then, in your sample output, you showed "01" in the position which would have contained JAN.

So, if that was a typo, then you're done. If you still need it to be converted, then it'll be a little more work but not difficult for you to do.

Notes: The backslash before the ls command forces it to ignore any aliases, so you don't end up trying to process the file's date, owner, etc. The structure is a basic for loop. The section containing the echo and Perl statement within the $() structure returns the output of that section (actually a subshell) to the current command line as a simple string.

ShawnMilo
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

problem knowing disk space

i am a fresh person learning sco open server 5.5:confused: how should i know that how much space is occupied & how much is free on a particular partition?please help (1 Reply)
Discussion started by: buntty
1 Replies

2. AIX

Knowing when is the user id expiring

HI, Do we have a command in AIX which will let us know when is the user id password getting expired!! Any advice will be of great help!! Thanks, Siddharth (0 Replies)
Discussion started by: siddhhuu
0 Replies

3. UNIX for Advanced & Expert Users

knowing progress while reading a file

Hi, I am parsing a very big file say 10 MB. It 'll take more than an hour ..I want to know the progress say in % .Is there any way to do that??? or (Is there any way to know which line of the file I am in ) (2 Replies)
Discussion started by: sakthi.abdullah
2 Replies

4. Solaris

Knowing global zone

Hi All, I was asked these question long time back, Is there any way to know frm non-global zone to know which is the global zone it belongs? As per my knowledge there is no way and i have looked for these topic for a quite a while and researched on it .I just want to be sure if i am... (1 Reply)
Discussion started by: sahil_shine
1 Replies

5. Shell Programming and Scripting

Knowing whether the file has completely SFTP ed

Hi.. Can Anyone out there help me? I need to write a script to convert a file in EDCIDC format to CSV The files will be transfered through sftp to the box. Is there a way to check the file has finished being transfered or still transfering. so that my conversion task will be performed after... (3 Replies)
Discussion started by: ramukandada
3 Replies

6. Shell Programming and Scripting

how to use the filehandle stored in a variable without knowing its file association

how to use the filehandle stored in a variable without knowing its file association i.e. the filename code my $logFH = $connObj->get('logFH'); infoPrint("Variable is of type IO \n") if(UNIVERSAL::isa($logFH, 'IO')); infoPrint("$logFH\n"); output == INFO :: Variable is of type... (0 Replies)
Discussion started by: rrd1986
0 Replies

7. UNIX for Dummies Questions & Answers

Knowing when a different program modifies a file

so i was testing something on a test box running linux. i manually vi'ed the /var/log/messages file. and i noticed, the file immediately stopped being updated. it wasn't until i restarted the syslog process that events started being recorded in it again. so that tells me, the syslog process... (20 Replies)
Discussion started by: SkySmart
20 Replies

8. Shell Programming and Scripting

As knowing which version has the awk?

friends How do I know which version of awk using my linux? (2 Replies)
Discussion started by: tricampeon81
2 Replies

9. Shell Programming and Scripting

Curl to download file from subdivx.com after following location without knowing the file name/extens

This question could be specific to the site subdivx.com In the past, I've been able to download a file following location using cURL but there is something about subdivx.com that's different and can't figure out how to get it to work. I tried the following directly in the terminal with no... (5 Replies)
Discussion started by: MoonD
5 Replies

10. UNIX for Advanced & Expert Users

Knowing the boot files

Hi, I have experienced a situation whereby after rebooting the server, we were not able to bring it up. After further troubleshooting it was found that it was an issue with the "boot" image/file permission. Have you experienced such an issue? I was not the one who did the troubleshooting... (1 Reply)
Discussion started by: anaigini45
1 Replies
rename(3tcl)						       Tcl Built-In Commands						      rename(3tcl)

__________________________________________________________________________________________________________________________________________________

NAME
rename - Rename or delete a command SYNOPSIS
rename oldName newName _________________________________________________________________ DESCRIPTION
Rename the command that used to be called oldName so that it is now called newName. If newName is an empty string then oldName is deleted. oldName and newName may include namespace qualifiers (names of containing namespaces). If a command is renamed into a different namespace, future invocations of it will execute in the new namespace. The rename command returns an empty string as result. EXAMPLE
The rename command can be used to wrap the standard Tcl commands with your own monitoring machinery. For example, you might wish to count how often the source command is called: rename ::source ::theRealSource set sourceCount 0 proc ::source args { global sourceCount puts "called source for the [incr sourceCount]'th time" uplevel 1 ::theRealSource $args } SEE ALSO
namespace(3tcl), proc(3tcl) KEYWORDS
command, delete, namespace, rename Tcl rename(3tcl)
All times are GMT -4. The time now is 12:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy