Sponsored Content
Full Discussion: Rename error message!
Top Forums Shell Programming and Scripting Rename error message! Post 50349 by Zeta_Acosta on Thursday 22nd of April 2004 05:40:19 AM
Old 04-22-2004
Rename error message!

Can anyone tell me why I keep on getting this error message?

../dosRename: syntax error at line 77: `end of file' unexpected

I have treid everything and I just can get it to work!
Here is the code:

#!/bin/sh

Usage() {
[ $# -ne 0 ] && echo "\n$*\n" >&2
cat <<-EOD_USAGE >&2
Usage: $0 file... target
file... List of files to rename
target Target name

EOD_USAGE
exit 1
}


# Get and verify arguments


# Argument count

[ $# -lt 2 ] && Usage "Missing arguments."

# Files to rename

while [ $# -gt 1 ]
do
file=$1
case "$file" in
*.*.*|*\**) Usage "Invalid file name : $file" ;;
esac
[ -e "$file" ] || Usage "File not found : $file"
file_list="$file_list $file"
shift
done

# Target name

target=$1
case "$target" in
*.*.*|*\**\**) Usage "Invalid target name : $file" ;;
esac
target_nam=`echo "$target" | cut -d. -f1`
target_ext=`echo "$target" | cut -d. -f2`


# Rename loop


for file in $file_list
do
# Actual file name and extension

file_nam=`echo "$file" | cut -d. -f1`
file_ext=`echo "$file" | cut -d. -f2`

# New file name and extension

if [ "$target_nam" = '*' ]
then new_nam="$file_nam"
else new_nam="$target_nam"
fi
if [ "$target_ext" = '*' ]
then new_ext="$file_ext"
else new_ext="$target_ext"
fi
[ -n "$file_ext" ] && file_ext=".$file_ext"
[ -n "$new_ext" ] && new_ext=".$new_ext"
new="${new_nam}${new_ext}"

# Rename

echo "Rename file $file to $new ..."
if [ -e "$new" ]
then echo "Not renamed, target file already exists : $new" >&2
else mv "$file" "$new"
fi
done

Many thanks.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Error message

I'm getting an error - symbol referencing errors. No output written to, etc Can anybody tell me why this is? (2 Replies)
Discussion started by: Dan Rooney
2 Replies

2. Solaris

lp error message

Both of these messages are filling up the /var/adm/messages files on these two Sun boxes, goober and gomer. The print server is called gold. Jul 31 03:15:40 gold bsd-gw: request to ma28084.Solaris (unknown printer) from goober Jul 31 03:16:39 gold bsd-gw: request to ma28084.Solaris (unknown... (1 Reply)
Discussion started by: antalexi
1 Replies

3. UNIX for Advanced & Expert Users

error message

I get this error message as soon as i log in -bash: /usr/local/software/.../vni/CTT6.0/ctt/bin/lopt64.sh: No such file or directory I looked into the etc/profile but there are no lines sourcing this file. And there is no lopt64.sh in the directory vni/.../bin I couldn't fogure out what... (4 Replies)
Discussion started by: dsmv
4 Replies

4. UNIX for Dummies Questions & Answers

getting last error message

Question for unix programmers - what function I need to used to get the exact error message when the library failed to load? Thanks (1 Reply)
Discussion started by: tttttt
1 Replies

5. Shell Programming and Scripting

Error message

I am new to scripting. I am using the following script . BART.dat contains the string 'Y' . #!/bin/ksh cd /work/TCI/data_out file=`cat BART.dat` echo "$file" if ; then echo "true" fi When i am executing the above script i am getting the following error ./s.ksh: : not found ... (2 Replies)
Discussion started by: ammu
2 Replies

6. UNIX for Dummies Questions & Answers

Error Message

I keep getting an error message in a script im writing, this line is allways pointed out. if and this is the message i keep getting. line 32: [: 8: unary operator expected Whats wrong with it? Please Help. (5 Replies)
Discussion started by: chapmana
5 Replies

7. UNIX for Dummies Questions & Answers

What does this Error Message Mean

Hi I found the following error message in my logs: warning: /etc/hosts.deny, line 6: can't verify hostname: getaddrinfo(localhost) didn't return ::ffff:222.255.28.33 What is the error message trying to indicate? That there is a problem with line 6 (2 Replies)
Discussion started by: mojoman
2 Replies

8. UNIX for Dummies Questions & Answers

Error Message

I am getting a error message when I try to assign this? Can someone help I am new to unix? $ First-name=james ksh:First-Name=james not found (1 Reply)
Discussion started by: vthokiefan
1 Replies

9. Shell Programming and Scripting

Perl script to rename file,error

#!/usr/bin/perl $FL="ch.txt"; $CFL="mytext.txt"; print "This script will rename textfiles."; mv $FL $CFL; print "Done."; perl file.pl Error: Can't locate object method "mv" via package "ch.txt" (perhaps you forgot to load "ch.txt"?) at file.pl line 7. (5 Replies)
Discussion started by: cola
5 Replies

10. Emergency UNIX and Linux Support

File rename error

hi im new for unix, when i try to rename the file im getting error $ mv -9file.jpg 9file.jpg error is mv: invalid option --"9" Try 'mv --help' for more information. (10 Replies)
Discussion started by: gwgreen1
10 Replies
SYSTEMD-CAT(1)							    systemd-cat 						    SYSTEMD-CAT(1)

NAME
systemd-cat - Connect a pipeline or program's output with the journal SYNOPSIS
systemd-cat [OPTIONS...] [COMMAND] [ARGUMENTS...] systemd-cat [OPTIONS...] DESCRIPTION
systemd-cat may be used to connect the standard input and output of a process to the journal, or as a filter tool in a shell pipeline to pass the output the previous pipeline element generates to the journal. If no parameter is passed, systemd-cat will write everything it reads from standard input (stdin) to the journal. If parameters are passed, they are executed as command line with standard output (stdout) and standard error output (stderr) connected to the journal, so that all it writes is stored in the journal. OPTIONS
The following options are understood: -h, --help Print a short help text and exit. --version Print a short version string and exit. -t, --identifier= Specify a short string that is used to identify the logging tool. If not specified, no identification string is written to the journal. -p, --priority= Specify the default priority level for the logged messages. Pass one of "emerg", "alert", "crit", "err", "warning", "notice", "info", "debug", or a value between 0 and 7 (corresponding to the same named levels). These priority values are the same as defined by syslog(3). Defaults to "info". Note that this simply controls the default, individual lines may be logged with different levels if they are prefixed accordingly. For details, see --level-prefix= below. --level-prefix= Controls whether lines read are parsed for syslog priority level prefixes. If enabled (the default), a line prefixed with a priority prefix such as "<5>" is logged at priority 5 ("notice"), and similar for the other priority levels. Takes a boolean argument. EXIT STATUS
On success, 0 is returned, a non-zero failure code otherwise. EXAMPLES
Example 1. Invoke a program This calls /bin/ls with standard output and error connected to the journal: # systemd-cat ls Example 2. Usage in a shell pipeline This builds a shell pipeline also invoking /bin/ls and writes the output it generates to the journal: # ls | systemd-cat Even though the two examples have very similar effects the first is preferable since only one process is running at a time, and both stdout and stderr are captured while in the second example, only stdout is captured. SEE ALSO
systemd(1), systemctl(1), logger(1) systemd 237 SYSTEMD-CAT(1)
All times are GMT -4. The time now is 04:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy