Jump to content

Hi.

I have decided to finally try andbecome active here....

Anyway, my question is that I've just started to use unix and I'm trying to find the 5576 or so word from the dictionary /usr/share/.........../..../dict/words

I also cn only use head tail cat

Any suggestions?

Link to comment
https://linustechtips.com/topic/464057-unix/
Share on other sites

Link to post
Share on other sites

i'm not so good with bash or the command line but in c++ i would say:

std::string nthWord(int n){std::string contents;std::ifstream in(filePath, std::ios::in | std::ios::binary);if (in) contents = std::string(std::istreambuf_iterator<char>(in), std::istreambuf_iterator<char>());else return -1;int proc = 0;int lineCount = 1;while (lineCount != n){if (contents.find("\n", proc) != std::string::npos){lineCount++;proc = contents.find("\n", proc);}else return -1;}return contents.substr(proc, contents.find("\n", proc));}

Probably needs some tweaking but you should get the idea if you understand c++.

If you don't understand it i'm sorry i could explain it more if you want

Link to comment
https://linustechtips.com/topic/464057-unix/#findComment-6228974
Share on other sites

Link to post
Share on other sites

Hi.

I have decided to finally try andbecome active here....

Anyway, my question is that I've just started to use unix and I'm trying to find the 5576 or so word from the dictionary /usr/share/.........../..../dict/words

I also cn only use head tail cat

Any suggestions?

can you explain? i do not know english well (i did not understand what you want) but i'm good at bash, python etc

so you have some file "words" with words in it and you want to get exactly 5576 words out of it?

how are words written in that file?

can you show me that files example?

Computer users fall into two groups:
those that do backups
those that have never had a hard drive fail.

Link to comment
https://linustechtips.com/topic/464057-unix/#findComment-6232412
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×