Sponsored Content
Top Forums Shell Programming and Scripting Problem renaming files on Solaris 10 server Post 302972263 by BRH on Tuesday 3rd of May 2016 12:46:01 PM
Old 05-03-2016
Problem renaming files on Solaris 10 server

Good day all.

I'm trying to rename some files in my home directory with some bizarre results. Basically I need to change the IP address in the filename to the hostname which I ggrep from within the file:

Code:
 
-rw-r--r--   1 bh694n   nrc         5095 May  2 20:03 alarms_999.189.161.146.log
-rw-r--r--   1 bh694n   nrc         4450 May  2 20:03 alarms_999.189.161.5.log
-rw-r--r--   1 bh694n   nrc         4398 May  2 20:03 alarms_999.189.175.143.log
-rw-r--r--   1 bh694n   nrc         4450 May  2 20:03 alarms_999.189.175.20.log
-rw-r--r--   1 bh694n   nrc         4397 May  2 20:03 alarms_999.190.152.231.log
-rw-r--r--   1 bh694n   nrc         4400 May  2 20:03 alarms_999.190.152.76.log
-rw-r--r--   1 bh694n   nrc         4397 May  2 20:03 alarms_999.190.161.232.log
-rw-r--r--   1 bh694n   nrc         5227 May  2 20:03 alarms_999.191.152.220.log
-rw-r--r--   1 bh694n   nrc         4429 May  2 20:03 alarms_999.191.152.77.log
-rw-r--r--   1 bh694n   nrc         4398 May  2 20:03 alarms_999.191.184.231.log
-rw-r--r--   1 bh694n   nrc         4419 May  2 20:03 alarms_999.191.184.52.log
-rw-r--r--   1 bh694n   nrc         5512 May  2 20:03 alarms_999.192.104.46.log
-rw-r--r--   1 bh694n   nrc         4398 May  2 20:03 alarms_999.192.106.46.log
-rw-r--r--   1 bh694n   nrc         5508 May  2 20:03 alarms_999.193.171.214.log
-rw-r--r--   1 bh694n   nrc         5453 May  2 20:03 alarms_999.193.171.53.log
-rw-r--r--   1 bh694n   nrc         4398 May  2 20:03 alarms_999.193.177.220.log
-rw-r--r--   1 bh694n   nrc         4397 May  2 20:03 alarms_999.193.177.52.log

The command string I used:
Code:
for i in `ls alarm*.log`;do HOST=`/usr/sfw/bin/ggrep -A 1 sysidconf $i|tail -1`;mv $i alarms_${HOST}.log;done

What I get is this:
Code:
bh694n$ ls -ltr        
total 180
.logr--r--   1 bh694n   nrc         5095 May  2 20:03 alarms_wa1dc02scg
.logr--r--   1 bh694n   nrc         4450 May  2 20:03 alarms_wa1dc01scg
.logr--r--   1 bh694n   nrc         4398 May  2 20:03 alarms_wy1pa02scg
.logr--r--   1 bh694n   nrc         4450 May  2 20:03 alarms_wy1pa01scg
.logr--r--   1 bh694n   nrc         4397 May  2 20:03 alarms_al1ga02scg
.logr--r--   1 bh694n   nrc         4400 May  2 20:03 alarms_al1ga01scg
.logr--r--   1 bh694n   nrc         4397 May  2 20:03 alarms_na1tn02scg
.logr--r--   1 bh694n   nrc         5227 May  2 20:03 alarms_ka1mo02scg
.logr--r--   1 bh694n   nrc         4429 May  2 20:03 alarms_ka1mo01scg
.logr--r--   1 bh694n   nrc         4398 May  2 20:03 alarms_sn1tx02scg
.logr--r--   1 bh694n   nrc         4419 May  2 20:03 alarms_sn1tx01scg
.logr--r--   1 bh694n   nrc         5512 May  2 20:03 alarms_cl1oh02scg
.logr--r--   1 bh694n   nrc         4398 May  2 20:03 alarms_ch1il02scg
.logr--r--   1 bh694n   nrc         5508 May  2 20:03 alarms_so1ca02scg
.logr--r--   1 bh694n   nrc         5453 May  2 20:03 alarms_so1ca01scg
.logr--r--   1 bh694n   nrc         4398 May  2 20:03 alarms_oa1ca02scg
.logr--r--   1 bh694n   nrc         4397 May  2 20:03 alarms_oa1ca01scg

Smilie

Where did I err?

Regards,
Bjoern
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Utility or script for renaming files on UNIX web server

Greetings! Does anyone know of a utility or a script for renaming files on a UNIX web server? I've seen several of these types of renaming utilities for Windows, but none for UNIX. I have 10,000 files that I need to rename in a several tier (deep) web site directory. I have the original... (1 Reply)
Discussion started by: everettr
1 Replies

2. Shell Programming and Scripting

Utility or script for renaming files on UNIX web server

Greetings! Does anyone know of a utility or a script for renaming files on a UNIX web server? I've seen several of these types of renaming utilities for Windows, but none for UNIX. I have 10,000 files that I need to rename in a several tier (deep) web site directory. I have the original... (2 Replies)
Discussion started by: everettr
2 Replies

3. UNIX for Advanced & Expert Users

problem with renaming files

Hi, I need to rename all the .txt files present in current directory to .dat files respectively in UNIX. for example: $ ls aaa.txt bbb.txt ccc.txt I need to change them to $ ls aaa.dat bbb.dat ccc.dat Is there any UNIX command to do this in one go? ... (3 Replies)
Discussion started by: Johny001
3 Replies

4. Shell Programming and Scripting

Loop renaming files w/ a count problem

:wall: Hello there, basically in my program where im stuck at is when it comes to rename the files in a loop. - the program counts the number of files w a given name (works!) - and then if the number of files is greater or equal to the MAX_VERSIONS (numbers of files allowed w the... (1 Reply)
Discussion started by: thurft
1 Replies

5. Shell Programming and Scripting

Help with renaming files in remote server

I have to write a script to get some files from remote server using FTP and rename it after the FTP. I use wildcard to get the file as i do not no the exact file name or the number of files in the remote server. My script is similar to the following... #!/bin/sh LOG=/Log/ftp.log ftp (FTP... (0 Replies)
Discussion started by: infossiva
0 Replies

6. Shell Programming and Scripting

Problem renaming files using variables

Hi, I have the following problem: I have a list of files: 1.txt 2.txt 3.txt 4.txt Then I have a list of variable names inside variable.txt: A B C D I'd like to rename 1.txt, 2.txt etc using the variables from variable.txt (2 Replies)
Discussion started by: hubleo
2 Replies

7. UNIX for Advanced & Expert Users

Problem with renaming files

I have about 1000 files containing the character * in the name. I need to find these files and replace the * with a -. I am working with HP UX v11. I am using the following command find . -type f -name '*\**' -exec bash -c 'f="$1"; mv "$f" "${f//\*/-}"' - '{}' \ People tell me it works for... (4 Replies)
Discussion started by: MikeDavid
4 Replies

8. Shell Programming and Scripting

Renaming Multiple Files in FTP Server

Hi Friends, I have a requirement to get multiple files from ftp(remote) server and once the files is copied to local machine , I need to move the files on to a different directory in ftp machine. FTP Machine : 9.9.999.999 Source File Directory : /ftpuser File Pattern: TMS* Now I have... (1 Reply)
Discussion started by: lokeshbao87
1 Replies

9. Shell Programming and Scripting

Renaming multiple files in sftp server in a get files script

Hi, In sftp script to get files, I have to rename all the files which I am picking. Rename command does not work here. Is there any way to do this? I am using #!/bin/ksh For eg: sftp user@host <<EOF cd /path get *.txt rename *.txt *.txt.done ... (7 Replies)
Discussion started by: jhilmil
7 Replies

10. Solaris

X-server problem on Solaris 10

Hi, On my Sun Ultra 45, display was flickering. After changing PCI slot of graphic card (XVR-300), display stablized, but, now X-server not starting. I am getting following messages The X-server can not be started on display : 0... See file/var/dt/Xerrors for details. the output of... (8 Replies)
Discussion started by: rakhsin
8 Replies
lltag_config(5) 						File Formats Manual						   lltag_config(5)

NAME
config - Configuration file for lltag DESCRIPTION
The following options may be stored in /etc/lltag/config or the user's $HOME/.lltag/config, or in any file passed with --config. Such a configuration file may also be generated with --gencfg. Obtaining tags format = "string" Add a user-defined format [-R]. Might be used multiple times. Default is to guess if no user-defined formats and no default field values are given. guess = <0/1> Try to guess if user-defined formats do not match [-G]. Default is 0 (disabled) when no user-defined formats and no explicit values are given. tag = <TAG=value> Add an explicit tag [--tag]. Might be used multiple times. Tweaking filename parsing no_path = <0/1> Do not use file path when matching filename [-p]. Default is 0 (disabled). spaces = <0/1> Allow no or multiple spaces [--spaces]. Default is 0 (disabled). Cleaning obtained tags edit = <0/1> Edit tags immediately [--edit]. Default is 0 (disabled). maj = <0/1> Upcase first letters of words in tags [--maj]. Default is 0 (disabled). regexp = "s/from/to/" Replace from with to in all tags. title,number:s/from/to/ replaces in title and number tags only. Might be used multiple times [--regexp]. Default is to not apply any regexp. sep = "string" Replace |-separated strings with space in tags. Default is to not replace any separator. Configuration of tag application type = <mp3|ogg|flac|none> Force mp3, ogg of flac instead of by-extension detection [--mp3, --ogg and --flac]. Default is none. clear_tags = <0/1> Clear all tags of audio files. [--clear]. Default is 0 (disabled). append_tags = <0/1> Append tags only instead of replacing old ones. [--append]. Default is 0 (disabled). no_tagging = <0/1> Do not actually tag files [--no-tagging]. Default is 0 (disabled). preserve_time = <0/1> Preserve file modification time during tagging [--preserve-time]. Default is 0 (disabled). Renaming rename_format = "string" Rename file according to format [--rename]. Default is to not rename. rename_min = <0/1> Lowcase tags before renaming [--rename-min]. Default is 0 (disabled). rename_regexp = "s/from/to/" Replace from with to in all tags before renaming. title,number:s/from/to/ replaces in title and number tags only. Might be used multiple times [--rename-regexp]. Default is to not apply any regexp. rename_sep = "string" Replace spaces with a string in tags before renaming [--rename-sep]. Default is to not replace any separator. rename_slash = "string" Replace slashes with a string in tags before renaming [--rename-slash]. Default is to replace with a dash. rename_ext = <0/1> Assume the rename format provides an extension [--rename-ext]. Default is 0 (disabled). Miscellaneous dry_run = <0/1> Do nothing but show what would have been done [--dry-run]. Default is 0 (disabled). yes = <0/1> Tag without asking for confirmation when guessing and rename without asking for confirmation [--yes]. Default is 0 (disabled). ask = <0/1> Always ask for confirmation before tagging [--ask]. Default is 0 (disabled). recursive = <0/1> Recursively traverse all given subdirectories [-R]. Default is 0 (disabled). verbose = <integer> Message verbosity level [-v and -q]. Default is 0 (only important messages). Other possible values are 1 (show usage information when a menu is displayed for the first time) and 2 (always show usage information before a menu appears). CDDB configuration cddb_server_name = hostname Change the CDDB server name. Default is www.freedb.org. cddb_server_port = <port> Change the CDDB server port. Default is 80 (HTTP). SEE ALSO
lltag(1) The config template file provided within the documentation directory. AUTHOR
Brice Goglin NOVEMBER 2006 lltag_config(5)
All times are GMT -4. The time now is 02:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy