- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: replacing ls from part of script
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
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
тАО08-21-2003 06:49 AM
тАО08-21-2003 06:49 AM
The piece of script is :
cd $PROPATHFILES
rc=0
if [ "`ls MB* X* OC* JO* CV* 2>/dev/null | grep -E -v '^XX|^XM|^XOX|^[0-9]'`" ]
then
#
# Create a file list.
# Done this way to ignore XX and XM files but include X* files
#
ls MB* X* OC* JO* CV* 2>/dev/null | grep -E -v '^XX|^XM|^XOX|^[0-9]' > $TMP/
CISAM_check_file_list
echo "Backing up CISAM files"
tar cvf - `cat $TMP/CISAM_check_file_list` | gzip -3 -c > $BACKUP_DIR/backup
/CISAM_backup.tar.gz
rc=$?
[ $rc -ne 0 ] && echo "Error $rc from 'gzip' - $TMP/CISAM_check_file_list"
else
echo "No CISAM files to backup in $PROPATHFILES"
fi
The problem being that the number of files the ls command finds is now too big and we get the following error:
sh: /usr/bin/ls: The parameter list is too long.
Any suggestions on a solution?
Solved! Go to Solution.
- Tags:
- Arg list too long
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-21-2003 06:59 AM
тАО08-21-2003 06:59 AM
Solutionexample-
cd $PROPPATHFILES
rc=0
ls | grep -e "^MB" -e "^X" -e "^OC" -e "^JO" -e "^CV" >/tmp/holdout2 | grep -E -v '^XX|^XM|^XOX|^[0-9]' >$TMP/CISAM_check_file_list
if [ -s $TMP/CISAM_check_file_list ] ; then
echo "Backing up CISAM files"
tar ...
HTH
-- Rod Hills
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-21-2003 07:01 AM
тАО08-21-2003 07:01 AM
Re: replacing ls from part of script
echo MB* X* OC* JO* CV* | grep ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-21-2003 07:05 AM
тАО08-21-2003 07:05 AM
Re: replacing ls from part of script
The "tar" command you are using may also get the error "parameter list is too long" if their are too many files.
You may want to look at "pax" or even "cpio", since both of them can take a list of files names for back up.
example-
cat $TMP/CISAM_check_file | pax -w -f - | gzip -3 -c >$BACKUP_DIR/backup/CISAM_backup.pax.gz
My 2 cents...
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-21-2003 07:07 AM
тАО08-21-2003 07:07 AM
Re: replacing ls from part of script
Correct line-
ls | grep -e "^MB" -e "^X" -e "^OC" -e "^JO" -e "^CV" | grep -E -v '^XX|^XM|^XOX|^[0-9]' >$TMP/CISAM_check_file_list
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-21-2003 07:14 AM
тАО08-21-2003 07:14 AM
Re: replacing ls from part of script
ls MB* > /tmp/filelist
ls OC* >> /tmp/filelist
ls JO* >> /tmp/filelist
ls CV* >> /tmp/filelist
ls X* | grep -E -v '^XX|^XM|^XOX|^[0-9] >> /tmp/filelist
Then do your checks on that file.
Its not as "clean" but it is straightforward.
Best regards,
Kent M. Ostby
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-21-2003 07:19 AM
тАО08-21-2003 07:19 AM
Re: replacing ls from part of script
Hi !
use find command
example :
# clear backup file :
>$BACKUP_DIR/backup/CISAM_backup.tar.gz
# find my pattern and tar :
for in MB OC JO CV pattern pattern ....
do
find $PROPATHFILES -name "$i*" -exec tar -xvf $BACKUP_DIR/backup/CISAM_backup.tar {} \ ;
-print 1>/tmp/my_list_of_files 2>/tmp/my_errors
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-21-2003 07:24 AM
тАО08-21-2003 07:24 AM
Re: replacing ls from part of script
In lieu of using 'ls' to collect the files meeting your criteria, you could use 'find':
# cd yourdir
# find . -path "./*" -prune -name "MB* X* OC* JO* CV*" -type f > $TMP/CISAM_check_file_list
This 'find' will not descend subdirectories so it will mimic a simple 'ls'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-21-2003 07:25 AM
тАО08-21-2003 07:25 AM
Re: replacing ls from part of script
The tar with -r
example :
# clear backup file :
>$BACKUP_DIR/backup/CISAM_backup.tar.gz
# find my pattern and tar :
for in MB OC JO CV pattern pattern ....
do
find $PROPATHFILES -name "$i*" -exec tar -rvf $BACKUP_DIR/backup/CISAM_backup.tar {} \ ;
-print 1>/tmp/my_list_of_files 2>/tmp/my_errors
done