Era, there's no need to apologise. You're just trying to help. I would go astray anyway while trying to find my way to the solution It would probably be worse if I am doing on my own without any help from you. I will update you again after trying your new suggestion. Thanks
Era, I have just remembered the problem of having an individual character in each case. I cannot key in cases as follows because I encountered syntax errors:
*`*) echo "Error";;
*\*) echo "Error";;
*)*) echo "Error";
*(*) echo "Error";
I tried adding "\" in front of each of the character, it failed too. I tried with *\`* but it failed to detect string with 678\989
Yes, you need to backslash-escape (or quote) any characters with special meaning.
Backslash in particular is special when reading too, but if you can just get the others to work, that's a start.
*\`* should match 678`989 not 678\989
Merely quoting closing parenthesis is insufficient, because it has a special meaning in the syntax of the case statement, and quoting won't help the parser, so you need the backslash specifically.
All of those should work IMHO, but $b might not contain a backslash when you expect it to. Consider:
See? The backslash is parsed already by read. My bash has an option read -r to disable this but I don't know if that's portable.
Last edited by era; 04-16-2008 at 03:07 AM..
Reason: Edit case example; character class is not sufficient for quoting
If anyone has a better solution, please let me know. I am still desperate for a solution. I regret for agreeing to use Bourne shell to develop this simple application.
Hi All, I am a newbie to Shell scripting. I have a requirement to Delimit the file fields of a Input file having special characters and spaces with ";".
Input File
----------------------------------
Server Port
----------------------------------
Local ... (5 Replies)
How to match a shell variable that contains parenthesis (and other special characters like "!")
file.txt contains:
Charles Dickens
Matthew Lewis (writer)
name="Matthew Lewis (writer)";
awk -v na="$name" ' $0 ~ na' file.txt
Ideally this would match $name in file.txt (in this... (3 Replies)
i need to replace the any special characters with escape characters like below.
test!=123-> test\!\=123
!@#$%^&*()-= to be replaced by
\!\@\#\$\%\^\&\*\(\)\-\= (8 Replies)
I made menu script for users so they can run other script without going in shell just from menu.
But i must control their input.
These are criteria:
Input must have 4 signs
First two signs are always lower case letters
Input shall not have some special signs just letters and numbers
... (1 Reply)
Hi,
I am trying to replace a string in shell but it is not working correctly.
@xcom.file@
needs to be replaced with
tb137
Plz help.Thx.
Please use and tags when posting code, data or logs etc. to preserve formatting and enhance readability, thanks. (4 Replies)
Hey Everyone,
I'm quite new to unix (hence the 0 posts!) and im trying to write a simple program that outputs what the user types in to the screen, as long as it is a letter.
This part works fine, however, when a "\" is entered doesnt not display anything and moves to the next line. Is... (11 Replies)
Hi Forum.
I've tried to search online for a solution but I cannot seem to find one.
Hopefully, someone here can help me out. I would appreciate it.
Input file abc.txt:
$InputFile_Borrower=CMTSLST\EDW_COMMERCIAL_MTGE_BORROWER_dat.lst... (14 Replies)
Hi,
I would like to display the following message from my shell (Korn) script
Copy "old_file.txt" to "new_file.txt"
My code looks as follows
print "Copy "old_file.txt" to "new_file.txt""
However, when I execute the script, I get the following output
Copy old_file.txt to... (6 Replies)
He guys.
Basically I want to make a script that can add, delete and view stuff in a external file called config.txt. I can open it up in Joe but im not sure how to read in the user input or using commands automatically in joe to edit, save then quit.
Problem area below:
1) echo "Add... (1 Reply)
I am struggling with the following sample code:
array1=(a b c d)
array2=(* * * *)
print ${array1}
print ${array2}
It returns 'c' and the name of a file in the directory I'm in.
I can't for the life of me work out how to prevent the shell interpreting the '*' and just get it to return... (2 Replies)