- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Scripting help
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
Forums
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
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
тАО12-10-2001 06:14 AM
тАО12-10-2001 06:14 AM
1. Scripts will need to scan a directory and find files begining w/ abc*
2. Then append all abc* files that were found to a new file named xyz.dat
3. After running another script to process xyz.dat file, will then need to delete only the abc* files that were found and the xyz.dat file.
Any suggestions would be appreciated.
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-10-2001 06:21 AM
тАО12-10-2001 06:21 AM
Re: Scripting help
cat abc* >xyz.txt
sh yourscript
rm abc* xyz.txt
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-10-2001 06:22 AM
тАО12-10-2001 06:22 AM
Re: Scripting help
cd to appropriate directory then
'find . -type f -name "abc*" >> xyz.dat'
As to question (3), what kind of processing would be done on xyz.dat?
To delete the files that are listed in xyz.dat, you can do this:
cat xyz.dat | xargs -i rm {}
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-10-2001 06:23 AM
тАО12-10-2001 06:23 AM
Re: Scripting help
How about:
===============================
#!/bin/ksh
dir=$1
cd $dir
find . -name "abc*" > xyz.dat
...
... process xyz.dat
...
cd $dir
cat xyz.dat | xargs rm
rm xyz.dat
==============================
then run with:
yourscript.sh directory-to-process
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-10-2001 06:27 AM
тАО12-10-2001 06:27 AM
Re: Scripting help
for FILENAME in (find . -name abc\*)
do
cat $FILENAME >>xyz.dat
FILES="$FILES $FILENAME"
done
... process xyz.dat
rm $FILES
-Santosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-10-2001 06:51 AM
тАО12-10-2001 06:51 AM
Re: Scripting help
I should have been more clear, but yes...I need to append the contents of the abc* files to xyz.dat. File xyz.dat is data that will be processed by a sql script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-10-2001 06:55 AM
тАО12-10-2001 06:55 AM
Re: Scripting help
'find . -type f -name "abc*" | xargs -i cat {} >> xyz.dat'
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-10-2001 07:06 AM
тАО12-10-2001 07:06 AM
Re: Scripting help
Santosh - I tried your script but get the following error:
/tmp # for FILENAME in (find . -name abc\*)
sh: Syntax error: `(' is not expected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-10-2001 07:38 AM
тАО12-10-2001 07:38 AM
Re: Scripting help
In that case, how about:
===============================
#!/bin/ksh
dir=$1
cd $dir
find . -name "abc*" > abc.dat
cat abc.dat | xargs cat >> xyz.dat
...
... process xyz.dat
...
cd $dir
cat abc.dat | xargs rm
rm xyz.dat
==============================
then run with:
yourscript.sh directory-to-process
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-10-2001 07:40 AM
тАО12-10-2001 07:40 AM
Solutionfind . -name abc\* -exec echo {} >>list_abc \;
find . -name abc\* -exec cat {} >>xyz.dat \;
execute the script
rm `cat list_abc` list_abc xyz.dat
Can be improved by making just one find, but since I am not a scripting wizard, like Clay for example, I couldn't make it in 5 minutes.
If it would be possible to make something like:
find . -name abc\* -exec echo {} >>list_abc && cat {} >>xyz.dat \;
it would be shorter. But it works with two 'find's anyway.
E.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-10-2001 07:48 AM
тАО12-10-2001 07:48 AM
Re: Scripting help
Got it!
find . -name abc\* -fprint list_abc -exec cat {} >>xyz.dat \;
execute script
rm `cat list_abc` list_abc xyz.dat
E.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-10-2001 09:40 AM
тАО12-10-2001 09:40 AM