find grep sed commands homework

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions find grep sed commands homework
# 8  
Old 02-12-2011
@scottn The sentences read like they have been translated from another language.


@ViruS89

4. it including five signs which was can read backwards

Some ideas for detecting a palindrome based on your example.

Code:
var1="Do geese see God"
var2="do Geese see goD"
echo "var1=${var1}"
echo "var2=${var2}"
echo ""
# Use the "tr" command to change upper case to lower case and remove spaces
var1_lower=`echo "${var1}"|tr 'A-Z' 'a-z'|tr -d ' '`
var2_lower=`echo "${var2}"|tr 'A-Z' 'a-z'|tr -d ' '`
echo "var1_lower=${var1_lower}"
echo "var2_lower=${var2_lower}"
echo ""
# Use the "rev" command to reverse the string
var2_lower_rev=`echo "${var2_lower}"|rev`
echo "var2_lower_rev=${var2_lower_rev}"
echo ""
if [ "${var1_lower}" = "${var2_lower_rev}" ]
then
        echo "This is a Palindrome"
else
        echo "This is not a Palindrome"
fi


var1=Do geese see God
var2=do Geese see goD

var1_lower=dogeeseseegod
var2_lower=dogeeseseegod

var2_lower_rev=dogeeseseegod

This is a Palindrome

# 9  
Old 02-12-2011
@methyl: Probably from Polish - by the O/P. A language translation would also have translated other parts of the post (the homework template headings, etc.), which are clearly not translated.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to find=grep or maybe sed/awk for multiple lines of text?

Hi, I am running the following: PASS="username/password" sqlplus -s << EOF | grep -v "^$" $PASS set feedback off set heading off set termout off select name from v\$database ; exit EOF Which gives ERROR: ORA-28002: the password will expire within 5 days PSMP1 (1 Reply)
Discussion started by: newbie_01
1 Replies

2. Shell Programming and Scripting

Help with Passing the Output of grep to sed command - to find and replace a string in a file.

I have a file example.txt as follows :SomeTextGoesHere $$TODAY_DT=20140818 $$TODAY_DT=20140818 $$TODAY_DT=20140818I need to automatically update the date (20140818) in the above file, by getting the new date as argument, using a shell script. (It would even be better if I could pass... (5 Replies)
Discussion started by: SriRamKrish
5 Replies

3. Shell Programming and Scripting

Join two commands sed and grep

Hi all, I have two separate commands which I would like to join. Basically, I want to match a line and insert a character at the end of the previous line to the matched line Here is what I have gotgrep -B1 '^>' sed 's/$/*/' Any help is much appreciated thanks (5 Replies)
Discussion started by: kaav06
5 Replies

4. UNIX for Dummies Questions & Answers

[Solved] Wildcards used in find, ls and grep commands

Platforms : Solaris 10 and RHEL 5.6 I always get double quotes , single quotes and asteriks mixed up for find, ls and grep commands. The below commands retrieve the correct results. But , unders stress , I get all these mixed up :mad: .So, i wanted to get a clear picture. Please check if... (7 Replies)
Discussion started by: John K
7 Replies

5. UNIX for Advanced & Expert Users

Find, Grep and then Sed

Example: I have folders 456 abc xyz 123 a1b I dont want to find in 123 and a1b. From rest folder i need to find in html and php files. find ./ -path "123" -prune and a1b find ./ -iname "*.htm*" -o -iname "*.shtm*" -o -iname "*.php" Now while finding i need to grep multiple... (7 Replies)
Discussion started by: nxvir
7 Replies

6. UNIX for Dummies Questions & Answers

using sed or grep to find exact match of text

Hi, Can anyone help me with the text editing I need here. I have a file that contains the following lines for example: (line numbers are for illustration only) 1 Hello world fantasy. 2 Hello worldfuntastic. 3 Hello world wonderful. I would like to get all those lines of text that... (5 Replies)
Discussion started by: risk_sly
5 Replies

7. Shell Programming and Scripting

Complex find grep or sed command

Haven't worked in bash for ages. did a good bit of shell scripting in regular sh, but have forgotten most of it. I have several thousand php files that now include the following line at the end of the file. There is no LF or CR/LF before it begins, it is just concatenated to the final line of... (3 Replies)
Discussion started by: sjburden
3 Replies

8. UNIX for Dummies Questions & Answers

help with find & grep commands

Folks; First about find: when i run this: find . -name '*log*' -mtime +10 -print | sed 's+^\./++;s+/.*++' | sort -u i got list of log files but also get a directories (although directory names doesn't have "log" in it). How can i exclude the directory from the output of this find command? ... (2 Replies)
Discussion started by: moe2266
2 Replies

9. UNIX for Dummies Questions & Answers

find and grep commands

I'm having trouble with the following commands i. count the number of lines which end in a 4 letter word grep '{4\}$' bfile <<seems to print out everything abc abc abcd joe joe john bob bill gregory greg greg gregory the grep command prints out the lines with 4 letter words and the... (3 Replies)
Discussion started by: StrengthThaDon
3 Replies

10. Shell Programming and Scripting

grep and sed to find a pattern and add newline

Hello All, I have log file the result from a multithreaded process. So when a process finishes it will write to this log file as 123 rows merged. The issue is sometimes the processess finish at the same time or write to the file at the same time as 123 rows merged.145 rows merged. At... (5 Replies)
Discussion started by: ssikhar
5 Replies
Login or Register to Ask a Question