I have a file called phone_dir.txt (2 lines for example):
ADAMS, Andrew 7583
BARRETT, Bruce 6466
I try to extract the last names and capitalize them, the output required is:
Adams
Barret
I can only use commands such as:
- cut
- paste
- tr
I tried running the following script but the results are inconsistent:
cut -c1 phone_dir.txt > last_names.txt | cut -f1 -d',' phone_dir.txt | cut -c2- | tr A-Z a-z | paste last_names.txt - | tr -d [:blank:]
Sometimes the output is:
Adams
Barret
And sometimes
dams
arret
Why are the results inconsistent?
awk
orperl
are more suited for this job... Is this homework ?