find grep sed commands homework

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions find grep sed commands homework
# 1  
Old 02-02-2011
find grep sed commands homework

Use and complete the template provided. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:
I have to make as home work several commands with gerp find and sed

2. Relevant commands, code, scripts, algorithms:
FIND command
-use command find to display all files, such that file is usual file and display all his line with inscription "MA"


GREP comand

display user with grep command form /etc/passwd

1. to display all login to begin and finishing with letter a or b
Code:

  Code:
  etc.users
 admina
 bserb
 broota


2. beginning and finishing with the same sign
Code:
Code:
  etc. users
aghata:....
roootr:....


3. to contain what the least three identical signs standing by me
Code:
Code:
  etc. users
 rooot:.....
admmmin:.....
ussser...


4. it including five signs which was can read backwards
Code:
Code:
  etc. users
      Do geese see God?  ->  do Geese see goD
      Devil lived   -> devil liveD



SED comand

1. replace multiple the pronouncement of any sign one such sign
Code:
 Code:
  etc. jfaghkjfhadglkjaaaadfgdffffffdddttttmmmm
      jfaghkjfhadglkjadfgdfdttm


2. replace every the pronouncement of sign aaaa bbb only and or only b


3. The attempts at a solution (include all code and scripts):
In find i try find . -type f -exec grep -l MA {} \;

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Nicolaus Copernicus University
Torun, Poland
professor Zyglarski Błazej
sk1-cw2
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
This User Gave Thanks to ViruS89 For This Post:
# 2  
Old 02-02-2011
Quote:
Originally Posted by ViruS89
4. it including five signs which was can read backwards
Code:
Code:
  etc. users
      Do geese see God?  ->  do Geese see goD
      Devil lived   -> devil liveD

I'll do this one for you.
Code:
$ grep '\([a-z]\)\([a-z]\)\([a-z]\)\([a-z]\)\([a-z]\).*\5\4\3\2\1' text
orizabus subaziro:ljjljlkjlk:roota:jkjhkjhk


"orizabus subaziro" besides being a palindrome is the real scientific name for some kind of insect.
This User Gave Thanks to Perderabo For This Post:
# 3  
Old 02-02-2011
I give another one :

Code:
$ echo "jfaghkjfhadglkjaaaadfgdffffffdddttttmmmm" | sed 's/\(.\)\1*/\1/g'
jfaghkjfhadglkjadfgdfdtm

sed 's/\(.\)\1*/\1/g' explanations :

s/pattern1/pattern2/g substitute pattern1 with pattern2 in a global manner (even if pattern1 occurs more than once in a line
.matches any single character
\( \) what is inside these backslash protected parenthesis is stored in the string \1
\1 refer to what has just been matched
* what is just before is repeated 0 or more times
\1 stand for the pattern2 which refer to the matched caracter

If you want to remove only adding successive occurrenc of ... let's say only letters a or t :

Code:
$ echo "jfaghkjfhadglkjaaaadfgdffffffdddttttmmmm" | sed 's/\([at]\)\1*/\1/g'
jfaghkjfhadglkjadfgdffffffdddtmmmm


Last edited by ctsgnb; 02-02-2011 at 05:41 PM..
This User Gave Thanks to ctsgnb For This Post:
# 4  
Old 02-12-2011
Who want make more ?
# 5  
Old 02-12-2011
Your point?

Make more what, exactly?

You want everyone just to give you all the answers?

What would you learn from that?
# 6  
Old 02-12-2011
@unix.com admin
Is there a link to post #1 in the original language?
# 7  
Old 02-12-2011
Quote:
Originally Posted by methyl
@unix.com admin
Is there a link to post #1 in the original language?
How are you viewing this page? It looks to be in the original language to me.
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