This is my first post, and I am relatively new to linux/unix scripts. I am writing a bash script in which I am trying to extract one line from another file and parse specific words from the line into an array. So for example, I have a file called SortScans in which the first 5 lines might look like this (nevermind that this file is in csh):
and in my new script, I want to create 2 arrays that would correspond just to what's inside those parentheses, where the end result would be the following 2 arrays
So here is the code that I am using so far in my script just to create RunsArray
#!/bin/bash
RUNS=`echo | awk 'NR==4 {print;exit}' SortScans`
sed -i 's/*(//' $RUNS
sed -i 's/)//' $RUNS
declare -a RunsArray
RunsArray=$RUNS
I don't really know what I'm doing there, I just sort of copy pasted different related things I've seen on forums. But I'm getting the following error on the sed part -
sed: can't read set: no such file or directory
and that error repeats for each word or number down the line (i.e. runs, =, (2, 3, 4, etc.)
Anybody think they can help me out? Like I said I'm just starting out, so if you think you have a better way of doing this altogether, I would love to hear it. Thanks y'all.
Thanks very much, I will try that. But will this work without the final forward slash for the sed command - after the } and before the '? Could you explain why it isn't needed there?