Go Job Hunting at the LQ Job Marketplace
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 12-04-2012, 01:07 AM   #1
Registered: Dec 2006
Location: Russia,52
Posts: 107

Rep: Reputation: 6
Question What is the size of command line


I want to install all rpms from folder using command:

rpm -i `ls packages`

but my friend said that output from ls command can be very long and it can overflow bash buffers.
What is the size of bash command line?
Old 12-04-2012, 01:47 AM   #2
LQ Veteran
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381
I do believe you are looking for this:
$ xargs --show-limits
Your environment variables take up 2762 bytes
POSIX upper limit on argument length (this system): 2092342
POSIX smallest allowable upper limit on argument length (all systems): 4096
Maximum length of command we could actually use: 2089580
Size of command buffer we are actually using: 131072

# or, little less accurate
$ getconf ARG_MAX

# or, previous command made accurate
$ echo $(( $(getconf ARG_MAX) - $(env | wc -c) ))
All 3 show the maximum character length of arguments.
1 members found this post helpful.
Old 12-04-2012, 01:49 AM   #3
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 968
Blog Entries: 2

Rep: Reputation: 232Reputation: 232Reputation: 232
It's not a bash limit but you can get the E2BIG error from the execve call.
Old 12-05-2012, 07:54 PM   #4
David the H.
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954
In any case, the use of ls here is not only unnecessary, but also wrong. The proper way to run the command is with a simple globbing pattern.

rpm -i *.rpm
If you need to avoid the max argument limit, you can do store the files in an array first, and loop over them.

rpmarray=( *.rpm )

for (( i=0; i<${#rpmarray[*]}; i+=25 )); do
	rpm -i ${rpmarray[@]:i:25}"
This will loop over all the files, processing 25 at a time.

I ran a quick test of the above on the entire content of my /etc directory, and it had no problems.

Do note though that the above relies on several bash extensions, and won't work properly in a posix-only shell. You'll have to use find and/or xargs if that's necessary.

See here for more on shell limits:
I'm getting "Argument list too long". How can I process a large list in chunks?


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
[SOLVED] vncviewer command line for view size? dokie80 SUSE / openSUSE 9 08-10-2010 10:05 AM
Increase the command line buffer size Akiles Linux - General 3 04-19-2005 11:17 AM
changing text size on command line anvilmonkey Linux - Software 1 03-21-2005 03:40 PM
command line font size poiuytrewq Linux - Newbie 8 09-21-2004 02:57 AM
Command Line Screen Size bgfay Linux - Newbie 2 06-22-2004 08:58 PM

All times are GMT -5. The time now is 11:23 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration