Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
hello.i have to find all the files which names is sound_x from a directory which call micro!!!the x is a variable and the files names are sound_5,sound_38,sound_101..etc...!!!then i should create a file(name newfile) which should contain the line 5 from the file sound_5,the line 38 from the file sound_38,the line 101 from the file sound_101. The newfile should be classified!for examble the line 5 should be over the line 38 in the new file!!!!
So far i have done only this...
find . -name "sound_*" fprint "temporary_files"
So far i have done only this...
find . -name "sound_*" fprint "temporary_files"
Then best look at your course material, ask your instructor to explain lessons 1 through 10 again or read some basic tutorials as you've shown no knowledge of shell scripting at all in this or your previous thread:
l had read the beginners tutorials and i have done my homework script which contains 9 questions,this is the only one which can not do it,to finish it!so if you have any idea to help me i appreciate more than junge me.
l had read the beginners tutorials and i have done my homework script which contains 9 questions,this is the only one which can not do it,to finish it!so if you have any idea to help me i appreciate more than junge me.
Sorry, but unSpawn gave you a good answer, with good direction.
If you have to write a script, and all you've done is ONE LINE....that's not much effort into it, especially when first two links that he provided tell you explicitly how to use variables, loops, etc. If you don't want people to 'junge' you, post the rest of the script you've written, and where you're stuck.
l had read the beginners tutorials and i have done my homework script which contains 9 questions,
It doesn't show. And backing up what script requirements you've posted only with a 'find' line doesn't show us anything that we can correct to help you with.
Quote:
Originally Posted by Christos Badogias
so if you have any idea to help me i appreciate more than junge me.
It's not a question of judging you or not. The reason why I said that is that asking for handouts doesn't make you learn anything. Here's what you want:
Sorry to shoot off at something of a tangent, but you are not helping yourself by making your posts easy to read. Here is your first post in this thread re-formatted to include things like capital letters, spaces between sentences and dropped the idiotic excess exclamation marks where it adds nothing at all to the meaning (I have no objection to the use of a single exclamation mark where something exceptional is being pointed out, or to emphasise a point that it easily missed, but to use them just because you are bored with full stops gets wearing very rapidly), so that readability is increased.
Hello.
I have to find all the files which have the name sound_x, from a directory which is called micro. The x is a variable and the files names are sound_5,sound_38,sound_101 (note, you seem to be saying that it is always an integer; that is not the same as saying that it a variable, so be as informative as possible)..etc...
I want to create a file (name newfile) which contains the line 5 from the file sound_5,the line 38 from the file sound_38,the line 101 from the file sound_101. This file, newfile, should be sorted, for example line 5 should be above line 38 in the new file.
So far all I have is this:
Code:
find . -name "sound_*" fprint "temporary_files"
I hope that you agree that this is more readable. While, in any case what you choose do up to you, you need to take into account that if your post is difficult to read, many people will just jump to another post and those who do come to your post may not be as helpful to you if you hadn't made them work to even understand what you are saying. Please do try to act in your own best interests.
This would only print out the literal string "files" and not the "x" position where the number is:
Code:
find ./micro -type f -name "sound_*.txt" | while read ITEM; do
NUMBER=$(echo ${ITEM}|cut -d "_" -f 2)
# ...or make it an array, then select array item 2:
# NUMBER=(${ITEM//_/ }); NUMBER=${NUMBER[1]}
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.