05-14-2007
Quote:
Originally Posted by emferrari
Hi
So, now my script is like this:
I repeat: Please put code inside CODE tags.
The following code doesn't give me any syntax errors, but I fixed the line breaks. Could that be your problem?
There are other issues with the script.
Quote:
for file in "$@"
do
INPUTFILE=$file
TEMPFILE=$INPUTFILE.$$
OUTPUTFILE=$INPUTFILE.new
# nr of arguments has to be 1
if [ $# -ne 1 ]
then
echo "\nUsage: $0 inputfile\n"
return 1
fi
You don't need to check for number of arguments, and if you give more than one file on the command line, this will cause the script to exit.
To exit from a script, use exit, not return; return is used to exit from functions and sourced scripts.
Quote:
# inputfile must exist and be readable
if [ ! -r $1 ]
then
echo "\nInputfile $file does not exist. Please enter a valid filename\n"
return 1
fi
echo "\nConvert File $INPUTFILE to $OUTPUTFILE"
tr "ÃÃÃöôÃäãÃÃüÃëêÃïîê¿"
"OOOOOOoooooAAAAAaaaaaaUUUUuuuuEEEEeeeeIIIIiiiiNnCcaS?" < $INPUTFILE >
$OUTPUTFILE
There should be the same number of characters in both strings (or more in the first).
Quote your variables. That will fail if any filenames contain spaces.
Quote:
# Change à to SS
# sed s/Ã/SS/g $OUTPUTFILE > $TEMPFILE
# mv $TEMPFILE $OUTPUTFILE
echo "...ready\n"
done
[mantas@IDBBANKMANTASDEV test]$ ./convertspecch.sh File*.txt
./convertspecch.sh[33]: syntax error: `newline' unexpected
What's wrong?
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I'm trying to delete lines from a large text file using VI.
Every line that I am wanting to delete start with 'S' - all others do not. (A list of users)
I've tried using * but doesn't seem to like it...any ideas...
Doesn't have to be VI - but I'm better with VI than sed/awk. (8 Replies)
Discussion started by: peter.herlihy
8 Replies
2. UNIX for Dummies Questions & Answers
when writing a shell script (bourne) and using a unix command like 'ls' is there anything special you need to do to use a wildcard (like *)? (3 Replies)
Discussion started by: benu302000
3 Replies
3. UNIX for Dummies Questions & Answers
ok, I'm trying to write a script file that lists files with specific elements in the name into a txt file, it looks like this
ls s*.dat > file_names.txt
can't figure out whats wrong with that line, any ideas?
thanks in advance (10 Replies)
Discussion started by: benu302000
10 Replies
4. UNIX for Dummies Questions & Answers
Hi All
Please excuse another straightforward question. When creating a tar archive from a directory I am attempting to use wildcards to eliminate certain filetypes (otherwise the archive gets too large). So I am looking for something along these lines.
tar -cf archive.tar * <minus all *.rst... (5 Replies)
Discussion started by: C3000
5 Replies
5. UNIX for Dummies Questions & Answers
find ./ -name t\* | sed "s@^./@@" > .filestobedeleted
j=$(wc -l < .filestobedeleted)
typeset -i cnt=0
typeset -i i=0
while read line
do
myarray=$line
((cnt = cnt + 1))
done < .filestobedeleted
while (1 Reply)
Discussion started by: aishu
1 Replies
6. Shell Programming and Scripting
Good evening All,
I have a perl script to pull out all occurrences of a files beginning with xx and ending in .p. I will then loop through all 1K files in a directory. I can grep for xx*.p files but it gives me the entire line. I wish to output to a single colum with only the hits found. ... (3 Replies)
Discussion started by: CammyD
3 Replies
7. UNIX for Dummies Questions & Answers
Im going insane trying to figure out what i consider a basic command on an SFTP server...
Im trying to download all files from a directory *done*
then remove all the files (and sometimes folders that contain files) i have downloaded on the remote directory...
the command i would normally... (2 Replies)
Discussion started by: mokachoka
2 Replies
8. UNIX for Advanced & Expert Users
These 2 websites do a GREAT job of explaining different types of wildcards. I learned about the categories of characters which I never knew about at all.
GNU/Linux Command-Line Tools Guide - Wildcards
GREP (1 Reply)
Discussion started by: cokedude
1 Replies
9. Shell Programming and Scripting
Does anyone know how I would go about inserting text at the beginning of a file with the file name containing a daily time stamp? Essentially I need to find the file name using a wild card, and then insert 3 lines of text - one of which is the processing date. Help please!? (1 Reply)
Discussion started by: cookie33
1 Replies
10. Shell Programming and Scripting
I have four files:
test
test2
test3
test4
I have this simple script:
#!/bin/bash
ls $1
Why does ./the_script.sh test* only list the first file, when a normal ls test* would list all four? What do I need to change in the script to be able to use wildcard? (12 Replies)
Discussion started by: KidCactus
12 Replies
LEARN ABOUT DEBIAN
gfcombine
GFCOMBINE(1) UserCommands GFCOMBINE(1)
NAME
gfcombine - combine a number of shares to form the original file
SYNOPSIS
gfcombine [-o OUTPUTFILE] INPUTFILE...
DESCRIPTION
Combine a set of files (as produced by gfsplit) to produce the original file by interpolating the shares on the commandline.
-o OUTPUTFILE
The name of the file to write out.
All INPUTFILEs should be called something.NNN where the .NNN is the share number. (The gfsplit tool will output files named appropriately).
The OUTPUTFILE if omitted will default to the name of the first INPUTFILE with the .NNN removed.
AUTHOR
Written by Daniel Silverstone.
REPORTING BUGS
Report bugs against the libgfshare product on www.launchpad.net.
COPYRIGHT
Copyright (C) 2006 Daniel Silverstone.
This is free software. You may redistribute copies of it under the terms of the MIT licence (the COPYRIGHT file in the source distribu-
tion). There is NO WARRANTY, to the extent permitted by law.
SEE ALSO
gfsplit(1), libgfshare(3), gfshare(7)
1.0.5 February 2006 GFCOMBINE(1)