started Unix yesterday, im 15 so i don't really know what i'm doing
The output of a file is:
File: IMAGE1.txt Resolution: 720 x 547 File: IMAGE2.txt Resolution: 720 x 547 File: IMAGE3.txt Resolution: 720 x 547 I want it to look like this: IMAGE1.txt: 720 x 547 IMAGE2.txt: 720 x 547 IMAGE3.txt: 720 x 547 Could somebody please explain how to do this, and also tell me exactly what you are doing. Thank You. Namaste and good luck! |
? Very vague question, I don't understand.
|
me neither.
|
first homework assignment?
Regardless, please tell us what commands you have studied. We can help and give hints, but it is established policy not to do the assignment for you. Here is a big hint: It can be done with a one-line SED command. The general form is this anything in <angle brackets>, means that you should insert the actual code. Code:
sed -n '/<keyword>/ {<get the next line>; <remove the line feed + the word "resolution">; <print the resulting line>}' <filename> > <newfilename> |
what i was thinking was i would set each file name to y and each resolution to z and then i would use echo to format them with the colon. I really just need to figure out how to set for y and zbecause what I have done already to get where i was at is this:
foreach x (`ls -1 | grep image `) sed -n 1,2p $x |
Quote:
Continuing my previous post: Look up the SED command here: http://www.grymoire.com/Unix/Sed.html |
no, I just dont understand the question. This is a really bad post because this is only my second day using any form of programming.
|
Quote:
Is "foreach" a legal command?---I've never seen it before |
yeah foreach is a legal command it just loops your commands, i think
|
Quote:
What commands did they teach you before making this assignment?----OR: Did they send you to some documentation to look up the commands? |
If you don't understand the question then how do you expect us to understand? Anyway, that script is wrong. Ls does not list contents of a file. What else have you tried, maybe if you tell us where you are stuck, instead of wanting the answer straight away. You will learn nothing like that sir.
|
they told me nothing, on my first day they just said do this, i knew no commands everything ive done so far has been from stuff ive looked up online.
|
Quote:
"man" is one the very first Linux /Unix commands to learn. enter "man man" to get some details on how it works |
im stuck because i dont know how to set the file name as a variable
|
thanks, i didnt know about the foreach thing.
|
All times are GMT -5. The time now is 07:10 AM. |