Sponsored Content
Top Forums Shell Programming and Scripting Problem renaming files on Solaris 10 server Post 302972266 by Don Cragun on Tuesday 3rd of May 2016 01:43:40 PM
Old 05-03-2016
The output from ggrep -A 1 sysidconf $i ends with a DOS <carriage-return><newline> character pair as a line terminator instead of the UNIX <newline> character line terminator.

Are these log files from a DOS system?

From where you are now, you should be able to recover using ksh or /usr/xpg4/bin/sh (not /bin/sh) to run the for loop:
Code:
for i in alarms*.log
do	mv "$i" "${i%?.log}.log"
done

and if you want to run your original script again and avoid this step, change it from:
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

to:
Code:
for i in alarm*.log;do HOST=`/usr/sfw/bin/ggrep -A 1 sysidconf "$i"|tail -1|tr -d '\r'`;mv "$i" "alarms_${HOST}.log";done

 

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
getusershell(3C)					   Standard C Library Functions 					  getusershell(3C)

NAME
getusershell, setusershell, endusershell - get legal user shells SYNOPSIS
#include <unistd.h> char *getusershell(void); void setusershell(void); void endusershell(void); DESCRIPTION
The getusershell() function returns a pointer to a legal user shell as defined by the system manager in the file /etc/shells. If /etc/shells does not exist, the following locations of the standard system shells are used in its place: /bin/bash /bin/csh /bin/jsh /bin/ksh /bin/ksh93 /bin/pfcsh /bin/pfksh /bin/pfsh /bin/sh /bin/tcsh /bin/zsh /sbin/jsh /sbin/pfsh /sbin/sh /usr/bin/bash /usr/bin/csh /usr/bin/jsh /usr/bin/ksh /usr/bin/ksh93 /usr/bin/pfcsh /usr/bin/pfksh /usr/bin/pfsh /usr/bin/sh /usr/bin/tcsh /usr/bin/zsh /usr/sfw/bin/zsh /usr/xpg4/bin/sh The getusershell() function opens the file /etc/shells, if it exists, and returns the next entry in the list of shells. The setusershell() function rewinds the file or the list. The endusershell() function closes the file, frees any memory used by getusershell() and setusershell(), and rewinds the file /etc/shells. RETURN VALUES
The getusershell() function returns a null pointer on EOF. BUGS
All information is contained in memory that may be freed with a call to endusershell(), so it must be copied if it is to be saved. NOTES
Restricted shells should not be listed in /etc/shells. SunOS 5.11 1 Nov 2007 getusershell(3C)
All times are GMT -4. The time now is 12:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy