- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- 'ls' command showing argument too long !!
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-08-2003 09:34 AM
тАО09-08-2003 09:34 AM
I just encountered a problem when running the 'ls -R /a/b/c/*' command .....and the system complained argument too long....
However, if I just use 'ls -F /a/b/c' and it works fine......also two different accounts run the first command will have different results....one was alright while the other complains argumen too long...
I am just wondering what's wrong with 'ls'...is there any buffer or environment variable I can set to get rid of this problem ??
FYI, I am using KSH
Many thanks,
Chris
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-08-2003 09:38 AM
тАО09-08-2003 09:38 AM
Re: 'ls' command showing argument too long !!
When using the wild card, the shell attempts to expand the file name using file name completion and the list simply ends up being too long. There is no way to change this shell behaviour, however, you can work around it using find:
find /a/b/c |xargs ll
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-08-2003 09:39 AM
тАО09-08-2003 09:39 AM
Re: 'ls' command showing argument too long !!
You may want to look and see if you have ls alias of some sort.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-08-2003 09:39 AM
тАО09-08-2003 09:39 AM
Re: 'ls' command showing argument too long !!
there is a limit, i think 1256 bytes.
When you issue an
ls -R /a/b/c/*
the shell expands the * to the list of names. If they are, in lenght, more than XXX, you get argument too long.
ls -R /a/b/c/
do not cause the expansio, because there are no wildcard.
Massimo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-08-2003 10:06 AM
тАО09-08-2003 10:06 AM
Re: 'ls' command showing argument too long !!
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x106937f45ef7d4118fef0090279cd0f9,00.html
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x5749c4c76f92d611abdb0090277a778c,00.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-08-2003 10:07 AM
тАО09-08-2003 10:07 AM
Re: 'ls' command showing argument too long !!
The difference between the -R & -F are as follows:
-R => list subdir contents as well as files.
-F => list subdir name & a symbol (/) that the entry is a subdir
The former will obviously have more entries, hence the "arg too long" msg
The account differences, I suspect, have something to do with ulimit differences.
The solution is to use the xargs (extended arguments) command.
HTH,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-08-2003 07:41 PM
тАО09-08-2003 07:41 PM
Solutionls -R /a/b/c/*
to
echo ls -R /a/b/c/*
and you'll see the same error. To see what the ls command sees in a smaller directory, do this:
echo ls /etc/*
Now tell the shell to stop expanding the * by escaping it's special meaning:
echo ls /etc/\*
and:
ls /etc/\*
The \ removes the special meaning of the * character. All this is covered in the manpages: man 5 regexp (the 5 is required, see man man)
So the error has nothing to do with ls but instead is a function of what the shell finds to match. For instance:
cd /a/b/c
ls -R
may work just fine because the expanded expanded list of matching filenames no longer contains the fullpath to this directory. However, add a few thousand more files to this directory and again you'll get the same error. When in doubt, use echo to see what your command line will look like after the shell finishes it's preprocessing.
---------------------------
For extra credit, here's a script that you can use to create 10,000 files to demonstrate the problem:
mkdir /var/tmp/dummy
cd /var/tmp/dummy
typeset -Z20 NUM=10000
while [ $NUM -gt 0 ]
do
touch IamAveryLONGfileNAMEtoSHOWcommandLINElimits_$NUM
let NUM=$NUM-1
done
Then use the * with either echo * or ls *
Warning: This will create a very large directory structure and will take a long time to create and also to remove.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-09-2003 09:30 PM
тАО09-09-2003 09:30 PM
Re: 'ls' command showing argument too long !!
I still got one more questions.....!! Since different accounts (with different profiles) will produce different results for the "ls /a/b/c/*" command.
e.g. an account with a few lines .profile and environment variable defined will be able to execute the above command
While an other account with hundreds of environment variable defined are unable to execute the above command.
I am just wondering whether the environment variables set to the user account (i.e. the .profile) will affect the behaviour of the command or should say affect the maximum argument length of the Unix command. and Why ? Is that the shell environment has been assigned with a limited amount of buffer or some structures that both the environment variables and the command line share ?
Appreciated for your advice and input.
Cheers,
Chris,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-09-2003 09:31 PM
тАО09-09-2003 09:31 PM
Re: 'ls' command showing argument too long !!
I still got one more questions.....!! Since different accounts (with different profiles) will produce different results for the "ls /a/b/c/*" command.
e.g. an account with a few lines .profile and environment variable defined will be able to execute the above command
While an other account with hundreds of environment variable defined are unable to execute the above command.
I am just wondering whether the environment variables set to the user account (i.e. the .profile) will affect the behaviour of the command or should say affect the maximum argument length of the Unix command. and Why ? Is that the shell environment has been assigned with a limited amount of buffer or some structures that both the environment variables and the command line share ?
Appreciated for your advice and input.
Cheers,
Chris,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-09-2003 09:32 PM
тАО09-09-2003 09:32 PM
Re: 'ls' command showing argument too long !!
I still got one more questions.....!! Since different accounts (with different profiles) will produce different results for the "ls /a/b/c/*" command.
e.g. an account with a few lines .profile and environment variable defined will be able to execute the above command
While an other account with hundreds of environment variable defined are unable to execute the above command.
I am just wondering whether the environment variables set to the user account (i.e. the .profile) will affect the behaviour of the command or should say affect the maximum argument length of the Unix command. and Why ? Is that the shell environment has been assigned with a limited amount of buffer or some structures that both the environment variables and the command line share ?
Appreciated for your advice and input.
Cheers,
Chris,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-09-2003 09:33 PM
тАО09-09-2003 09:33 PM
Re: 'ls' command showing argument too long !!
I still got one more questions.....!! Since different accounts (with different profiles) will produce different results for the "ls /a/b/c/*" command.
e.g. an account with a few lines .profile and environment variable defined will be able to execute the above command
While an other account with hundreds of environment variable defined are unable to execute the above command.
I am just wondering whether the environment variables set to the user account (i.e. the .profile) will affect the behaviour of the command or should say affect the maximum argument length of the Unix command. and Why ? Is that the shell environment has been assigned with a limited amount of buffer or some structures that both the environment variables and the command line share ?
Appreciated for your advice and input.
Cheers,
Chris,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-10-2003 03:57 AM
тАО09-10-2003 03:57 AM
Re: 'ls' command showing argument too long !!
What may be happening is that the argument list is different because of the specific directory permissions or (more likely) the ls command itself is not really the default built-in. For example:
alias ll='/usr/bin/ls -alF'
might be in a user's .profile so to see what a user 'really' is running, do this:
type ls
(type is an alias for whence -v) Unlike which and whereis, the type/whence command tells you exactly what will happen when you type a particualr string. Here are some examples:
type pwd ls ll for fc passwd
The ls -a option will return more filenames (ie, 'hidden' or dot-files). Do this in each user environment:
echo * | wc
This will tell you what * will return for a psecific user. Differences will be due to what the user is allowed to see based on user and group permissions.
Bill Hassell, sysadmin