LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   splitting array (https://www.linuxquestions.org/questions/linux-newbie-8/splitting-array-912940/)

ted_chou12 11-10-2011 11:50 PM

splitting array
 
Sorry I havent do this for quite a long while already, I intend to split a text into array
the text roughly looks like:
Code:

a
b
c
d

so far i came up with:
Code:

array=(echo $text | cut -d'
' f1)

the enter is the deliminator and f1 intends to cut out the first string, since -f1 means to take f1 only, so i thought it would be the other way around.

my intention is to make a new text that looks like:
Code:

b
c
d

so line a is deleted.


Thanks,
Ted

grail 11-11-2011 01:07 AM

I am a bit lost? Are you saying you want to remove the 'a' line from the file? If so, can you not just use sed to delete the line?

ted_chou12 11-11-2011 03:01 AM

Hi, thanks for the reply,
I did this:
Code:

echo ${text#*
}

Ted

grail 11-11-2011 05:24 AM

Well I have no idea why but if your happy :)

Juako 11-11-2011 06:51 AM

use sed

Code:

sed -n '1!p' < text
or head
Code:

head -n1 < text

ted_chou12 11-11-2011 07:06 AM

thanks :) I am happy.


All times are GMT -5. The time now is 05:10 PM.