LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-28-2005, 10:20 AM   #16
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239

this works...

Code:
while read line;do

   set -- $line                       ##  set $1 $2 $3 etc

   tag="$1"
   shift

   while [ $# -gt 1 ] ;do             ## while parameters left > 1
     desc="$desc $1"
     shift                            ## shift 'em all up one
   done

   status=$1                          ## should be one left here

   echo tag=$tag
   echo desc=$desc
   echo status=$status
   echo  "============"

  unset desc

done
data
Code:
tag1 this has three good
tag2 this has three no five  good
tag3 zero bad
tag5 this has lots and lots and lots  bad
result
Code:
bash 2 < data
tag=tag1
desc= this has three
status=good
============
tag=tag2
desc= this has three no five
status=good
============
tag=tag3
desc= zero
status=bad
============
tag=tag5
desc= this has lots and lots and lots
status=bad
============

Last edited by bigearsbilly; 07-28-2005 at 10:23 AM.
 
Old 07-28-2005, 02:07 PM   #17
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
this is close:

threadid=343482

you basically want to tokenize your input
 
  


Reply



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 script – reading and writing variables to a separate file morrolan Programming 10 09-20-2005 07:45 AM
Reading a conf file from a BASH script dinolinux Programming 5 08-03-2005 04:18 AM
Need help reading text file in bash script scilec Programming 3 11-25-2004 06:44 PM
Bash script - reading from text file twantrd Programming 4 11-24-2004 12:38 AM
reading file, bash script marri Programming 3 11-15-2004 09:13 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:47 PM.

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
Open Source Consulting | Domain Registration