Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam EX200 topic 1 question 6 discussion

Actual exam question from RedHat's EX200
Question #: 6
Topic #: 1
[All EX200 Questions]

SIMULATION -
Find the rows that contain abcde from file /etc/testfile, and write it to the file/tmp/testfile, and the sequence is requested as the same as /etc/testfile.

Show Suggested Answer Hide Answer
Suggested Answer: See explanation below.
# cat /etc/testfile | while read line;
do
echo $line | grep abcde | tee -a /tmp/testfile
done

OR -
grep `abcde' /etc/testfile > /tmp/testfile

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
airphreak
Highly Voted 3 years, 4 months ago
grep abcde /etc/testfile > /tmp/testfile
upvoted 22 times
...
adolfoale
Highly Voted 3 years, 3 months ago
cat /etc/testfile | grep "abcde" > /tmp/testfile
upvoted 13 times
...
Bittercampari
Most Recent 2 months, 3 weeks ago
awk '/abcde/ {print}' /etc/testfile >> /tmp/testfile
upvoted 1 times
...
thomasstate
5 months ago
this is my error message after i executed the command grep abcde /etc/testfile > /tmp/testfil "grep : /etc/testfile: Is a directory"
upvoted 1 times
...
ertgrty
8 months, 1 week ago
#grep "abcde" /etc/testfile > /tmp/testfile
upvoted 1 times
...
Rahul95
11 months ago
#touch /tmp/testfile - if file doesn't exists #grep abcde /etc/testfile > /tmp/testfile #cat /tmp/testfile - to verfy
upvoted 1 times
...
Velda
1 year, 1 month ago
There is no specified if the content of destination file can be replaced. So i suppose that it can.. in that case these commands are correct: cat /etc/testfile | grep abcde > /tmp/testfile OR grep abcde /etc/testfile > /tmp/testfile In case that content of destination file should not be replaced, following command will work: cat /etc/testfile | while read line; do echo $line | grep abcde | tee -a /tmp/testfile; done There is missing ";" in "correct answer" here, so the command from there will work if you will copy paste it but if you need to write it on your own, you must add the ";" or use bash script!
upvoted 2 times
...
techzideas
1 year, 2 months ago
grep -w "abcde" /etc/testfile >> /tmp/testfile
upvoted 1 times
...
ktd971
1 year, 3 months ago
grep ^abcde$ /etc/testfile > /tmp/testfile
upvoted 1 times
...
ptmude
2 years, 3 months ago
grep abcde /etc/testfile | tee /tmp/testfile
upvoted 1 times
...
eid
2 years, 4 months ago
cat /etc/testfile | grep abcde > /tmp/testfile OR grep abcde /etc/testfile > /tmp/testfile
upvoted 4 times
...
MELO225
2 years, 7 months ago
cat /etc/tesfile | grep abcde > /tmp/testfile
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...