Hey. I'm just getting started with scripting and although i will admit i haven't searched the forum yet, i think it would be a waste of time. It really will be very simple.
I want to enter a list of arguments after my script with the last being the filename. (not the first, as this is part of the requirements)
I so far have
Now i have put every variation i can think of around the second lines var in order the change the value of filename to be from the location in the list of arguments to the argument itself, ie if i put
sh script hi there smelly
smelly is the last argument.
i want the filename to take on the value of the file smelly, not the value 3 (3rd argument)
if i put sh script hi there scriptfile1
where scriptfile1 exists and is the file i want to to point to, it still has argument 3. Whilst I would rather have it point to a file that already exists, i don't mind if it creates a new tempfile, (and will do checks on if files exist once i can get this sorted) i would just like to know how i can have it point to a filename rather than the argument number.
I'm sure i've made that a lot more difficult that it is, but any advice would be appreciated.
Hey. I'm just getting started with scripting and although i will admit i haven't searched the forum yet, i think it would be a waste of time.
Well, we don't think it would be a waste of time. That is why the rules state:
(5) Search the forums database with your keywords before asking.
Had you searched the forums maybe you have found printing last argument in shell script or one of the dozens of other threads that answer your question. Please give the search function a try next time.
Thanks for the reply. Although I'm sure you wont believe me, I read the rules before I posted.
After posting the question I realised that it wasn't clear. In the example I used above, I was after the last argument (which the thread you suggested does show how to do) but my question was as per the second article. That is to say it could be anywhere within the argument list. If i were to search, the terms I would be using would be position, argument, file, all terms ubiquitous to most threads. That is why i chose against searching.
Thanks for your response.
Mitch.
P.S. I am a nice guy, and understand where you are coming from. I know from experience what it is like partaking in forums where people ask questions that have been asked a hundred times before. I didn't just ignore the search feature off the cuff. Sorry if I pi**ed you off.
Last edited by spudtheimpaler; 10-21-2006 at 02:16 PM..
I have a text file (allWords.txt), that I would like to search through. Here is a snippet of what it looks like...
a
aah
aahed
aahing
aahs
aardvark
aardvarks
aardwolf
ab
abaci
aback
abacus
abacuses
abaft
......
I would like to use the grep search to search, line by line, for... (8 Replies)
Cheers!
In /etc/syslog.conf, if an error type is not specified, is it logged anywhere (most preferable is it logged to /var/log/messages) or not?
To be more precise I am interested in error and critical level messages. At default these errors are not specified in syslog.conf, and I need to... (6 Replies)
Hello all!
This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician.
Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix:
... (16 Replies)
Hello;
we have :
awk '/reg_exp/,0/
prints every line after the first occurrence of "reg_exp"
But if I want to print rest of the lines AFTER the last occurrence of "reg_exp",
how would I do it ??
Tried :
awk ' ! (/reg_exp/,0)'
But it errored...
Thank you for any... (5 Replies)
Hello
I am trying to do global search on access log files for a date and for either 'Error|error' string
ls -lrt *access* | grep "Sep 23" | awk '{print $9}'|xargs awk '/23\/Sep\/2011/ && /Error/ || /error'
Above matches All lines with 'error' as well unfortunately.
Is there a... (6 Replies)
hi there,
I am a complete newb to bash but am going to try and make a script to help me seach text files for strings of interest, any help that one of you gurus could pass on will be greatly received!!
I want to write something like:
in "text1.txt" find "string1" and copy out the line... (7 Replies)
Hi
I need to define a pattern that will match an open square bracket, a series of numbers fro 1 to 4 digits in length and a close square bracket. Examples of the numbers I will need to find are:
or
or
or
I am using BBEdit to search, and BBEdit uses the standard GREP search... (1 Reply)
I have a ascii file with lines like this:
240|^M\ ^M\^M\ Old Port Marketing order recd $62,664.- to ship 6/22/99^M\
when this record gets loaded into my database, the \ is stored literally and so the user sees carriage return \ (hex 0D 5C) when what i need is carriage return line feed (hex 0D... (1 Reply)
in vi, if i type ctrl-J, i can shift the next line up to the current line.
I need to do this whenever a specific string exists (in particular ^M) ,however i have not been able to find a way to do this in vi, sed, or awk
seems simple enough.
can someone help me?
thanks in advance (9 Replies)