Skip to main content
added 47 characters in body
Source Link
Zac
  • 569
  • 4
  • 11
  • 17

In my simple database, it contains text of like, example, soldiers.

Name:Rank:Gender:Age:Years of Service

Tom Corporal:Recruit:Male:19:2
Nicole Sergeant:Corporal:Female:30:10
Daniel Recruit:Sergeant:Male:40:19

And my script goes like this:

echo "Enter name: "
read name

echo "Enter rank: "
read rank

echo "Enter gender: "
read gender

echo "Enter age: "
read age

echo "Enter Years of service: "
read years

grep $name database.txt

If I enter "Corporal" into name, the output will show

Tom Corporal:Recruit:Male:19:2
Nicole Sergeant:Corporal:Female:30:10

because the string matches under the section name and rank. How do i use delimiter : to categories the search, so if i enter my conditions under rank, it will search just the rank category and not everything else.

Thanks in advance.

And do up my question instead of down voting.

In my simple database, it contains text of like, example, soldiers.

Name:Rank:Gender:Age:Years of Service

Tom Corporal:Recruit:Male:19:2
Nicole Sergeant:Corporal:Female:30:10
Daniel Recruit:Sergeant:Male:40:19

And my script goes like this:

echo "Enter name: "
read name

echo "Enter rank: "
read rank

echo "Enter gender: "
read gender

echo "Enter age: "
read age

echo "Enter Years of service: "
read years

grep $name database.txt

If I enter "Corporal" into name, the output will show

Tom Corporal:Recruit:Male:19:2
Nicole Sergeant:Corporal:Female:30:10

because the string matches under the section name and rank. How do i use delimiter : to categories the search, so if i enter my conditions under rank, it will search just the rank category and not everything else.

Thanks in advance.

In my simple database, it contains text of like, example, soldiers.

Name:Rank:Gender:Age:Years of Service

Tom Corporal:Recruit:Male:19:2
Nicole Sergeant:Corporal:Female:30:10
Daniel Recruit:Sergeant:Male:40:19

And my script goes like this:

echo "Enter name: "
read name

echo "Enter rank: "
read rank

echo "Enter gender: "
read gender

echo "Enter age: "
read age

echo "Enter Years of service: "
read years

grep $name database.txt

If I enter "Corporal" into name, the output will show

Tom Corporal:Recruit:Male:19:2
Nicole Sergeant:Corporal:Female:30:10

because the string matches under the section name and rank. How do i use delimiter : to categories the search, so if i enter my conditions under rank, it will search just the rank category and not everything else.

Thanks in advance.

And do up my question instead of down voting.

In my simple database, it contains text of like, example, soldiers.

Name:Rank:Gender:Age:Years of Service

Tom TankCorporal:Recruit:Male:19:2
Nicole DanSergeant:Corporal:Female:30:10
Daniel RalRecruit:Sergeant:Male:40:19

And my script goes like this:

echo "Enter name: "
read name

echo "Enter rank: "
read rank

echo "Enter gender: "
read gender

echo "Enter age: "
read age

echo "Enter Years of service: "
read years

grep $name database.txt

And ifIf I want to find viaenter "Corporal" into name, the gender and i type in "male".

My code to findoutput will beshow

grep $gender Information.txt | cut -f 3Tom -dCorporal:Recruit:Male:19:2
Nicole Sergeant:Corporal:Female:30:10

Howeverbecause the string matches under the section name and rank. How do i use delimiter : to categories the search, that line does not workso if i enter my conditions under rank, any help ?it will search just the rank category and not everything else.

Thanks in advance.

In my simple database, it contains text of like, example, soldiers.

Name:Rank:Gender:Age:Years of Service

Tom Tank:Recruit:Male:19:2
Nicole Dan:Corporal:Female:30:10
Daniel Ral:Sergeant:Male:40:19

And my script goes like this:

echo "Enter name: "
read name

echo "Enter rank: "
read rank

echo "Enter gender: "
read gender

echo "Enter age: "
read age

echo "Enter Years of service: "
read years

And if I want to find via the gender and i type in "male".

My code to find will be

grep $gender Information.txt | cut -f 3 -d :

However, that line does not work, any help ? Thanks in advance.

In my simple database, it contains text of like, example, soldiers.

Name:Rank:Gender:Age:Years of Service

Tom Corporal:Recruit:Male:19:2
Nicole Sergeant:Corporal:Female:30:10
Daniel Recruit:Sergeant:Male:40:19

And my script goes like this:

echo "Enter name: "
read name

echo "Enter rank: "
read rank

echo "Enter gender: "
read gender

echo "Enter age: "
read age

echo "Enter Years of service: "
read years

grep $name database.txt

If I enter "Corporal" into name, the output will show

Tom Corporal:Recruit:Male:19:2
Nicole Sergeant:Corporal:Female:30:10

because the string matches under the section name and rank. How do i use delimiter : to categories the search, so if i enter my conditions under rank, it will search just the rank category and not everything else.

Thanks in advance.

Post Closed as "Duplicate" by muru, Hauke Laging, Anthon, Nidal, jasonwryan
formatting
Source Link
pbm
  • 26k
  • 6
  • 39
  • 51

In my simple database, it contains text of like, example, soldiers.

Name:Rank:Gender:Age:Years of Service

Tom Tank:Recruit:Male:19:2 Nicole Dan:Corporal:Female:30:10 Daniel Ral:Sergeant:Male:40:19

Name:Rank:Gender:Age:Years of Service

Tom Tank:Recruit:Male:19:2
Nicole Dan:Corporal:Female:30:10
Daniel Ral:Sergeant:Male:40:19

And my script goes like this:

echo "Enter name: " read name

echo "Enter rank: " read rank

echo "Enter gender: " read gender

echo "Enter age: " read age

echo "Enter Years of service: " read years

echo "Enter name: "
read name

echo "Enter rank: "
read rank

echo "Enter gender: "
read gender

echo "Enter age: "
read age

echo "Enter Years of service: "
read years

And if I want to find via the gender and i type in "male".

My code to find will be grep $gender Information.txt | cut -f 3 -d “:”

grep $gender Information.txt | cut -f 3 -d “:”

However, that line does not work, any help ? Thanks in advance.

In my simple database, it contains text of like, example, soldiers.

Name:Rank:Gender:Age:Years of Service

Tom Tank:Recruit:Male:19:2 Nicole Dan:Corporal:Female:30:10 Daniel Ral:Sergeant:Male:40:19

And my script goes like this:

echo "Enter name: " read name

echo "Enter rank: " read rank

echo "Enter gender: " read gender

echo "Enter age: " read age

echo "Enter Years of service: " read years

And if I want to find via the gender and i type in "male".

My code to find will be grep $gender Information.txt | cut -f 3 -d “:”

However, that line does not work, any help ? Thanks in advance.

In my simple database, it contains text of like, example, soldiers.

Name:Rank:Gender:Age:Years of Service

Tom Tank:Recruit:Male:19:2
Nicole Dan:Corporal:Female:30:10
Daniel Ral:Sergeant:Male:40:19

And my script goes like this:

echo "Enter name: "
read name

echo "Enter rank: "
read rank

echo "Enter gender: "
read gender

echo "Enter age: "
read age

echo "Enter Years of service: "
read years

And if I want to find via the gender and i type in "male".

My code to find will be

grep $gender Information.txt | cut -f 3 -d “:”

However, that line does not work, any help ? Thanks in advance.

Source Link
Zac
  • 569
  • 4
  • 11
  • 17
Loading