![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Find a path of a specific file | samir_standing | Shell Programming and Scripting | 11 | 10-29-2008 07:19 PM |
| Change Specific Line of a File | msb65 | UNIX for Dummies Questions & Answers | 10 | 08-20-2008 10:18 PM |
| How to change a specific character in a file | sdubey | Shell Programming and Scripting | 6 | 02-22-2008 03:30 PM |
| Script to delete logs or take backups under specific user | namishtiwari | Shell Programming and Scripting | 12 | 01-25-2008 06:31 AM |
| Delete specific lines in a text file | dniz | High Level Programming | 9 | 08-08-2005 08:30 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Script to change/find/delete/install a specific file
Hi
Very much a newbie to UNIX & scripting, but have identified an area within work that would benefit from being automated, as its repeated manually very often, and it looks like the ideal first script! What I need to do is change directory to a users home (cd ~), and then find and remove a specific file (in the format .abcd). The final part of my script will then be to unpack a cpio package to the users home path. Although I know the basic Unix commands to do this step by step, i'm unsure as to how this can be interpreted into a shell, to run it automatically. Any advice would be hugely appreciated. |
|
||||
|
Thanks very much vbe.
This is what I have so far- cd ~ ~/.mozilla ls -a echo "Do you wish to remove and re-install the .mozilla profile? Y/N" read answer echo "The answer is $answer" exit 1 rm -rf .mozilla cpio -icvdum < /pcms/data/mozilla_install.cpio echo "Mozilla has been re-installed " What I need to do now is get it so that if the answer to the echo is "Y", then the script continues (to remove the .mozilla), if not, to exit the script? Regards Kip |
|
||||
|
All the help so far has been cracking, cheers all!
One last thing i'm just wondering..... Is there a command where I can check if a directory exists, before removing it? If it does, I want the script to remove it and the proceed to the reinstall. If not, I want it to create it and proceed to the install? Regards Kip |
|
||||
|
Quote:
Code:
if [ -d $dir_name ] then echo "dir $dir_name is available" else echo "dir $dir_name is not available" fi |
![]() |
| Bookmarks |
| Tags |
| shell script, shell scripting, unix commands, unix scripting, unix scripting basics |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|