Something went wrong!

Some error occured while loading page for you. Please try again.

  • Practice
  • Compete
  • Jobs
  • Leaderboard
  1. Dashboard
  2. Linux Shell
  3. Arrays in Bash
  4. Filter an Array with Patterns

Filter an Array with Patterns

by PRASHANTB1984
  • Problem
  • Submissions
  • Leaderboard
  • Discussions

Objective
We now transition to some basic examples of bash scripting for the purpose of text processing and data munging. In this challenge, we practice reading and filtering an array.

Resources
Here's a great tutorial with useful examples related to arrays in Bash.

Task
You are given a list of countries, each on a new line. Your task is to read them into an array and then filter out (remove) all the names containing the letter 'a' or 'A'.

Input Format

The input format consists of a list of country names, each on a separate line. The only characters present in the country names will be upper or lower case characters and hyphens.

Output Format

From the given list, remove the names that contain 'a' or 'A' in them. If there are no names left after removing these characters, you should display a blank line.

Sample Input

Namibia
Nauru
Nepal
Netherlands
NewZealand
Nicaragua
Niger
Nigeria
NorthKorea
Norway

Sample Output

Niger

Explanation

Niger is the only name that does not contain an 'a' or 'A'.

Medium
Submitted 3519 timesMax Score 1

Need Help?

View Discussions
View Top Submissions

Rate This Challenge:

Download problem statement
Download sample test cases
Suggest Edits
Set as default

You can always change back later.

Contest Calendar | Blog | Scoring | Environment | FAQ | About Us | Support | Careers | Terms Of Service | Privacy Policy | Request a Feature