- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- awk and untarring an entire dir.
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
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
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
10-23-2001 07:36 AM
10-23-2001 07:36 AM
The goal is to gather all tar mother balls that have a prefix of 'sfib' or 'vins' and untar them (sfib or vins).
I have created and output file and I awk the output file to list column $9 and if it meets a certain criteria then follow the logic that is in the script. What am I doing wrong with my 'while' and 'do' statements? Is there a way for me to untar all tar files within a directory? If anyone can help, I will crown the:-)
Below is a cut and paste of the script.
----------------------------------------------
#!/bin/ksh
cd /home/s1perf/test_dir
ls -l > /home/s1perf/test_dir/mother_tar
awk '{print$9}' /home/s1perf/test_dir/mother_tar | sort | while (read sfib) ; do
if [[ -f $DATA/$sfib.tar ]] ; then
awk '{print $9}' /home/s1perf/test_dir/mother_tar | sort | while read vins ;
if [[ -f $DATA1/$vins.tar ]] ; then
mv -R /home/s1perf/test_dir/*sfib.tar /home/s1perf/test_dir/test_dump ;
mv -R /home/s1perf/test_dir/*vins.tar /home/s1perf/test_dir/test_dump
fi
cd /home/s1perf/test_dir/test_dump
tar -xvf *$9.tar
etc
chmod 777 */*
rm *$9.tar
exit $9.tar
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2001 07:51 AM
10-23-2001 07:51 AM
Re: awk and untarring an entire dir.
I think there is some confusion in your scripts and I hope I understand your "prefix" thing.
When you wrote
awk '{print $9}' /home/s1perf/test_dir/mother_tar|sort |while (read sfib)
do
...
You are not checking for the condition that the prefix should be sfib here.. Right?...
You may want to do this probably...
#!/usr/bin/ksh
cd /home/s1perf/test_dir
for i in "sfib vins"
do
cp -Rp $i*.tar test_dump
done
cd test_dump
tar xvf *.tar
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2001 07:52 AM
10-23-2001 07:52 AM
SolutionThis should be faily easy.
dumpdir=cd /where/to/put/them
cd /where/your/files/are
ls sfib* vins* | while read line
do
mv $line $dumpdir/.
done
cd $dumpdir
for x in `ls *.tar`
do
tar xvf $x
done
Hope this helps.
...jcd...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2001 07:55 AM
10-23-2001 07:55 AM
Re: awk and untarring an entire dir.
Why not do this:
#/bin/ksh
SRC_DIR=/home/s1perf/test_dir
DEST_DIR=/home/s1perf/test_dir/test_dump
cd $SRC_DIR
for FILE in $SRC_DIR/*sfib.tar $SRC_DIR/*vins.tar
do
if [[ -r $FILE ]]
then
FILENAME=$(basename $FILE)
mv -R $FILE $DEST_DIR
tar xvf $DEST_DIR/$FILENAME
fi
done
Or something like that...
-Santosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2001 07:56 AM
10-23-2001 07:56 AM
Re: awk and untarring an entire dir.
If your idea is to just untar all the tar balls that start with sfib or vins, we don't really need to use loops..
cd /home/s1perf/test_dir
cp -Rp sfib*.tar test_dump
cp -Rp vins*.tar test_dump
cd test_dump
tar xvf *.tar
rm *.tar
Is this not what you want?
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2001 10:33 AM
10-23-2001 10:33 AM
Re: awk and untarring an entire dir.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2001 10:42 AM
10-23-2001 10:42 AM
Re: awk and untarring an entire dir.
In the former (or if the man page fails) you can always try "brute force".
y | tar xvf *
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2001 10:42 AM
10-23-2001 10:42 AM
Re: awk and untarring an entire dir.
yes| tar xvf *
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2001 12:43 PM
10-23-2001 12:43 PM
Re: awk and untarring an entire dir.
Thanks for the response Alan, but I am still getting (untar the follwoing tar file? [y] [n]) prompts when I run the following script:
----------------------------------------------
#!/bin/ksh
dumpdir=/home/s1perf/test_dir/test_dump
cd /home/s1perf/test_dir
ls sfib* vins* | while read line
do
mv $line $dumpdir/.
done
cd $dumpdir
for x in `ls *.tar`
do
yes| tar xvf $x
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2001 12:51 PM
10-23-2001 12:51 PM
Re: awk and untarring an entire dir.
It is surprizing. I never saw tar asking
yes no questions.
Can you manually try to untar without keeping
it in a script and see if it works?.
#mkdir /tmp/junk;cd /tmp/junk
#tar xvf /home/s1perf/test_dir/somespecific.tar
See if this asks you yes or no?.
Surprizing :-()
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2001 12:58 PM
10-23-2001 12:58 PM
Re: awk and untarring an entire dir.
which tar
what $(which tar)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2001 01:34 PM
10-23-2001 01:34 PM
Re: awk and untarring an entire dir.
I will not forget to give points.
-Chris