Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
|
01-11-2017, 06:36 PM
|
#16
|
Member
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310
Original Poster
Rep:
|
Well I want to do exactly as I stated above. I ran it as it is and I like it! It reminds me of some stored procs I created in stinky windows! For right now I think this is one of those tasks that I prefer to do manually
Last edited by trickydba; 01-11-2017 at 06:38 PM.
|
|
|
01-12-2017, 08:46 AM
|
#17
|
Member
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310
Original Poster
Rep:
|
This is what I came up with so far. I have not ran it yet but I hoped that someone would see this ode and correct any errors:
Code:
#!/bin/bash
OPTION=$(whiptail --title "Multi-Folder Compressor - By Me" --menu "Choose the month range to compress" 15 60 4 \
"0" "CANCEL" \
"1" "January to June" \
"2" "July to December" \
"3" "Specify custom month range FUTURE OPTION" \
"4" "FUTURE" 3>&1 1>&2 2>&3)
clear
YEAR=$(whiptail --inputbox "Please input the year" 10 30 3>&1 1>&2 2>&3)
#Actions to take based on selection
{
if [[ ${OPTION[1]} ]]; then
#Option 1 selected
echo "Option 1 selected"; find . -name '0101*-0631*' | xargs tar -czvf JanJun${YEAR}.tar.gz
fi
if [[ ${OPTION[2]} ]]; then
#Option 2 selected
echo "Option 2 selected"; find . -name '0701*-1231*' | xargs tar -czvf JulyDec${YEAR}.tar.gz
fi
if [[ ${OPTION[3]} ]]; then
#Option 3 selected
echo "This option is under construction"
fi
if [[ ${OPTION[4]} ]]; then
#Option 4 selected
echo "This option is for FUTURE use"
fi
if [[ ${OPTION[0]} ]]; then
#Option 5 selected
echo "You chose to cancel"
fi
}
I would like to include a progress bar if selecting option 1 or 2.
Last edited by trickydba; 01-12-2017 at 01:16 PM.
|
|
|
01-12-2017, 10:06 AM
|
#18
|
Moderator
Registered: Aug 2002
Posts: 26,273
|
At first glance OPTION is not an array and you might want to specify the full path to your search directory and tar.gz file.
I have not played with whiptail much so can not help with its gauge box.
|
|
1 members found this post helpful.
|
01-12-2017, 10:19 AM
|
#19
|
Member
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310
Original Poster
Rep:
|
@michaelk............How do I do this? I created this from other sources and I only have limited knowledge of java which led me to what I have now. I have another script much simpler that I figured I should start out with(the 1st code I provided is much prettier 8.) )
I created several blank folders, ranging 01012017 through 12312017. There will be other folders to cover all days in a year but I only created this for a starting point. This is the SECOND OPTION of code I'm working with that is much simpler. The folders are in the same directory:
Code:
#! /bin/bash
echo "***************** Multi-folder Compressor ****************
****************** By Me **********************
Please choose an option:
1)Compress Jan to Jun
2)Compress Jul to Dec
3)FUTURE USE
4)Disabled "
read n
clear
echo "Please provide the year "
read YEAR
case $n in
1) echo "Compressing folders Jan to Jun "; find . -name '0101*-0631*' | xargs tar -cf JanJun${YEAR}.tar.gz;;
2) echo "Compressing folders Jul to Dec "; find . -name '0701*-1231*' | xargs tar -cf JulDec${YEAR}.tar.gz;;
3) echo "For future use....closing ";;
4) echo "This option is disabled ";;
*) invalid option;;
esac
I get this error:
Compressing folders Jan to Jun
tar: Cowardly refusing to create an empty archive
I'm lost. Any help is highly appreciated BUT I love that 1st code, with the pretty menu n colors n all! 8.))
Last edited by trickydba; 01-12-2017 at 01:18 PM.
|
|
|
01-12-2017, 10:30 AM
|
#20
|
Senior Member
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth&Mars (I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that work on freest-HW; has been KDE, CLI, Novena-SBC but open.. http://goo.gl/NqgqJx &c ;-)
Posts: 4,888
|
I can recommend [CODE][QUOTE][/QUOTE][/CODE] [B]tags![/B]
|
|
1 members found this post helpful.
|
01-12-2017, 10:31 AM
|
#21
|
Member
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310
Original Poster
Rep:
|
@jamison200003.........what is that? Where do I plug it in?
|
|
|
01-12-2017, 10:35 AM
|
#22
|
Senior Member
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth&Mars (I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that work on freest-HW; has been KDE, CLI, Novena-SBC but open.. http://goo.gl/NqgqJx &c ;-)
Posts: 4,888
|
Quote:
Originally Posted by trickydba
@jamison200003.........what is that? Where do I plug it in?
|
I forget the quick keys but if you hit "go advanced" here you get more LQ editor options to clarify your text with...
|
|
1 members found this post helpful.
|
01-12-2017, 10:39 AM
|
#23
|
Senior Member
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth&Mars (I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that work on freest-HW; has been KDE, CLI, Novena-SBC but open.. http://goo.gl/NqgqJx &c ;-)
Posts: 4,888
|
|
|
1 members found this post helpful.
|
01-12-2017, 10:42 AM
|
#24
|
Moderator
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,900
|
Excellent point jamison20000e.
@trickydba, what they are recommending is that you either use the advanced editor and properly frame code using [code][/code] tags, there are tools available in the advanced edit mode.
Further, you can also manually type these tags in, and the ones for use in LQ are located here, and discussed in the FAQ here.
Edit: Just noticed their added reply also arrived about the same time. Yes, same link.
|
|
1 members found this post helpful.
|
01-12-2017, 10:44 AM
|
#25
|
Moderator
Registered: Aug 2002
Posts: 26,273
|
All I implied is that whiptail does not return an array so instead of ${OPTION[x]} you would use $OPTION.
The case syntax is not correct in your second script. You need to use ;; to separate each items code.
There are many ways to create menus with or without a window.
|
|
1 members found this post helpful.
|
01-12-2017, 01:15 PM
|
#26
|
Member
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310
Original Poster
Rep:
|
I apologize all....
@michaelk............How do I do this? I created this from other sources and I only have limited knowledge of java which led me to what I have now. I have another script much simpler that I figured I should start out with(the 1st code I provided is much prettier 8.) )
I created several blank folders, ranging 01012017 through 12312017. There will be other folders to cover all days in a year but I only created this for a starting point. This is the SECOND OPTION of code I'm working with that is much simpler. The folders are in the same directory:
Code:
#! /bin/bash
echo "***************** Multi-folder Compressor ****************
****************** By Me **********************
Please choose an option:
1)Compress Jan to Jun
2)Compress Jul to Dec
3)FUTURE USE
4)Disabled "
read n
clear
echo "Please provide the year "
read YEAR
case $n in
1) echo "Compressing folders Jan to Jun "; find . -name '0101*-0631*' | xargs tar -cf JanJun${YEAR}.tar.gz;;
2) echo "Compressing folders Jul to Dec "; find . -name '0701*-1231*' | xargs tar -cf JulDec${YEAR}.tar.gz;;
3) echo "For future use....closing ";;
4) echo "This option is disabled ";;
*) invalid option;;
esac
I get this error:
Compressing folders Jan to Jun
tar: Cowardly refusing to create an empty archive
I'm lost. Any help is highly appreciated BUT I love that 1st code, with the pretty menu n colors n all! 8.))
|
|
|
01-12-2017, 01:35 PM
|
#27
|
Moderator
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,900
|
Not sure if this is the exact problem; however June has only 30 days.
Hence 0631 is an invalid search term.
You probably won't get it, but "use your knuckles".
January, left, upper index knuckle = 31 days.
February, dip between index and second finger = 28/29 days.
March, next upper digit knuckle = 31 days.
...
July is the upper digit of your pinky, 31 days
Go back to the index finger, August is 31 days.
Finish the year.
Or just remember that all months alternate between 31 and 30 or the special case of February. And then remember that July/August are both 31.
|
|
1 members found this post helpful.
|
01-12-2017, 01:56 PM
|
#28
|
Member
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310
Original Poster
Rep:
|
This is my final code:
Code:
#!/bin/bash
OPTION=$(whiptail --title "Multi-Folder Compressor - By Me " --menu "Choose the month range to compress" 15 60 4 \
"0" "CANCEL" \
"1" "January to June" \
"2" "July to December" \
"3" "Specify custom month range FUTURE OPTION" \
"4" "FUTURE" 3>&1 1>&2 2>&3)
clear
YEAR=$(whiptail --inputbox "Please input the year" 10 30 3>&1 1>&2 2>&3)
#Actions to take based on selection
case $OPTION in
1) echo "Compressing folders Jan to Jun "; find . -name '0101*-0630*' | xargs tar -cf JanJun${YEAR}.tar.gz;;
2) echo "Compressing folders Jul to Dec "; find . -name '0701*-1231*' | xargs tar -cf JulDec${YEAR}.tar.gz;;
3) echo "For future use....closing ";;
4) echo "This option is disabled ";;
*) invalid option;;
esac
and I get this error:
Code:
Compressing folders Jan to Jun
tar: Cowardly refusing to create an empty archive
I chose #1
Last edited by trickydba; 01-12-2017 at 01:57 PM.
|
|
|
01-12-2017, 02:02 PM
|
#29
|
Moderator
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,900
|
Break that down. Enter the find command manually and verify that it finds the files. Combine that with your tar command. Use "set -xv" in the command line to see what the error is, also consider using that in the script. Perhaps the find command is not working or finding the correct files and thus it outputs nothing. After all, look what the error is saying.
|
|
1 members found this post helpful.
|
01-12-2017, 03:18 PM
|
#30
|
Member
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310
Original Poster
Rep:
|
@rtmistler......I couldn't find the issue after doing what you suggested. If you have folders created like '01012017' that go all the way to '12312017' and you wanted to tar them to one file named as such 'JanJun.tar' and 'JulDec.tar' how can this be done?
I researched doing this with files but couldn't find anything for compressing folders.
|
|
|
All times are GMT -5. The time now is 02:56 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|