Go Job Hunting at the LQ Job Marketplace
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


Search this Thread
Old 07-15-2005, 11:10 AM   #1
LQ Newbie
Registered: Jul 2005
Posts: 2

Rep: Reputation: 0
parsing standard input with bash

Hi! I'm trying to set a variable with the standard input but i have a problem. For example:

user@work005:~> input some command done by me with ten parameters or more

In mi bash script I have
field2=$2 ...

fields 1 to 9 i don't have troubles, but field 10 sets "$field1"0, it means


and I need filed10=or

What should I do? Thanks in advance...

Last edited by arosales; 07-15-2005 at 11:20 AM.
Old 07-15-2005, 11:15 AM   #2
LQ Newbie
Registered: Jul 2005
Posts: 2

Original Poster
Rep: Reputation: 0
RE: parsing standard input with bash

I just have to enclosed it in {brackets}



(I have to read more before post)

Last edited by arosales; 07-15-2005 at 11:21 AM.
Old 07-15-2005, 11:26 AM   #3
Senior Member
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 326Reputation: 326Reputation: 326Reputation: 326
If the number of positional parameters ($#) is greater than 9, then you can use the 'shift' bash command to get the remaining parameters. See 'man bash' for details. For example:

shift 9

Last edited by macemoneta; 07-15-2005 at 11:27 AM.
Old 07-16-2005, 10:42 AM   #4
Registered: May 2005
Posts: 378

Rep: Reputation: 33
Re: parsing standard input with bash

Originally posted by arosales
Hi! I'm trying to set a variable with the standard input but i have a problem.
To be pedantic, you're not setting your variables from standard input, but from command line parameters.


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
Standard Input in Perl Program eachow Linux - General 2 11-17-2005 12:16 AM
utf , standard output / input and grep too Fascistchicken Linux - Software 2 11-05-2004 08:52 AM
parsing a user input string daphne19 Programming 1 04-22-2004 07:40 AM
my mouse input is takes as keyboard input in BASH e1000 Slackware 5 12-08-2003 03:00 PM
stty: standard input: Inappropriate ioctl for device fwalthard Linux - General 0 07-14-2003 02:55 AM

All times are GMT -5. The time now is 09:01 AM.

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