What bash command line utilities do I need?
I want to create 2 column list.The first column goes from 1-5,the second column being the number of entries in the file /data/share/files/text that has the
number of characters listed in the first column.The content of the text file is copied below: L Lin Linux Dis Dist Book Downl Bookm Press green I dont know the commands or combination of commands to do this.Any help would be greatly appreciated. |
Your example text file has entries with more than 5 characters. You didn't indicate what to do if a line has more than 5 characters.
I think you want to read the info bash manual. You can assign a line to a variable and use a form of variable reference that returns the number of characters in the variable. Also read the section on arrays in bash. You don't need to use any core utils or text utils for this simple example. Bash can count the characters for you. I'm just giving you a hint in the right direction because this looks like a homework assignment. |
No,Its not!This is something Im trying to do on my own.But,..I will try to read on arrays in bash and see if it helps.An example would be nice to steer me in the right direction.Not sure..a sed? a grep? an awk? or a combination of all of them.
|
youll probably want to use cut and paste
|
Yeah! sure.Im not even gonna pay attention to your nonsense.
|
These actually *ARE* command-line tools with what may
appear to be /strange/ names for someone with a Gooey background .... Cheers, Tink |
If the size of the file isn't too large, you can read it into an array like this:
text=( $( cat file) ) Try playing with these commands, and reference the bashref manual to see what they are doing. Code:
http://tldp.org/LDP/abs/abs-guide.pdf |
Great,thanks a lot for your help.Its greatly appreciated I will try these commands and see what happens.
|
Quote:
man cut man paste these are commands |
All times are GMT -5. The time now is 03:20 PM. |