Thought i'd have a bash at learning UNIX as I mostly know scripting languages or higher level OO based languages. Got to admin its all a little confusing and I am attempting to example questions I found from various sites. First one is to write a script that takes two arguments a file and a string and inputs the string at top of file and in middle line of file.
I know how to get the number of lines from a file i.e.
wc -w File
But I am unsure how to use that as a variable in my script. All that I have read about variables is simple assignment i.e.
I dont know how to assign the return of a function to the variable i.e.
myVariable=wc -w File
doesnt seem to work. And I dont think its possible to redirect to variables is it? i.e.
wc -w File > $LineCount
Once I have the line numbers I can determine where to add the string but I wouldnt know how to do this either. I would guess that to add the string in the middle line of the file I would first assign the head lines of a variable then append the var to add the sting then append it to add the tail values. But again I dont know how to assign the results of the Tail and Head returns to a file i.e.
$Text= Tail -$First
Am I completely off the mark here with what I am wanting to do? I think i probably am and the other questions are alot harder still.
Thanks in advance,