LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-10-2011, 11:50 PM   #1
ted_chou12
Member
 
Registered: Aug 2010
Location: Zhongli, Taoyuan
Distribution: slackware, windows, debian (armv4l GNU/Linux)
Posts: 425
Blog Entries: 28

Rep: Reputation: 2
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

Last edited by ted_chou12; 11-11-2011 at 12:25 AM.
 
Old 11-11-2011, 01:07 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,494

Rep: Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867
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?
 
Old 11-11-2011, 03:01 AM   #3
ted_chou12
Member
 
Registered: Aug 2010
Location: Zhongli, Taoyuan
Distribution: slackware, windows, debian (armv4l GNU/Linux)
Posts: 425
Blog Entries: 28

Original Poster
Rep: Reputation: 2
Hi, thanks for the reply,
I did this:
Code:
echo ${text#*
}
Ted
 
Old 11-11-2011, 05:24 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,494

Rep: Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867
Well I have no idea why but if your happy
 
Old 11-11-2011, 06:51 AM   #5
Juako
Member
 
Registered: Mar 2010
Posts: 202

Rep: Reputation: 84
use sed

Code:
sed -n '1!p' < text
or head
Code:
head -n1 < text
 
1 members found this post helpful.
Old 11-11-2011, 07:06 AM   #6
ted_chou12
Member
 
Registered: Aug 2010
Location: Zhongli, Taoyuan
Distribution: slackware, windows, debian (armv4l GNU/Linux)
Posts: 425
Blog Entries: 28

Original Poster
Rep: Reputation: 2
thanks I am happy.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash string splitting into array praveenhm Programming 14 10-26-2010 02:51 PM
Server array (mysql, php) -> gboolean array in c client kalleanka Programming 1 07-27-2010 06:50 AM
[SOLVED] shell script help: copying directory list into an array and then accessing the array richman1234 Linux - Newbie 6 07-25-2010 11:19 PM
bash: use file as input into array, parse out other variables from array using awk beeblequix Linux - General 2 11-20-2009 10:07 AM
splitting numbers and characters from an array of characters. trscookie Programming 6 11-14-2008 09:34 AM


All times are GMT -5. The time now is 06:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration