Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have a small shell script that starts a program when I double-click it. (I have set the permissions to allow executing the script).
I want to be able to copy that script to another computer so that the new user can double-click it without needing to know anything about chmod or permissions. But I can't find out how to preserve the execute permission when I copy the file.
I can usually find answers with Google but this has me defeated - I guess I am not expressing my question properly.
Thanks
Use rsync or tar.
rsync -p file user#host:destdir
plus other options you might need.
Or
tar cvzf file.tar file
then copy (or email, etc.) file.tar to the other machine and extract the file:
tar xpvzf file.tar
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
Im trying to write a script that keeps a tar in sync with a folder. I am dealing with a lot of files and don't want to remake the tar every time the script is run. I want it to only add/remove files from the tar that have been added/removed from the folder since the last script run. Here's what I have.
# Create tar if it doesn't exist but don't over write if it does exist
touch -a /home/MyName/data.tar
cd /home/MyName
# Make the tar
tar -uv --exclude='dirToTar/FileIWantToExclude' -f $tarFile dirToTar
This works great for adding files. But if a file is deleted from dirToTar, it doesn't get removed from data.tar.
Unfortunately, tar just doesn't support this. As an alternative, you could use zip, like this:
zip -r -FS myArchiveFile.zip dirToZip
Not "tar" like you asked for, but it does seem to work nicely. Another alternative would be to use 7z (the 7-zip archiver), which may give you better compression. The command-line options for this is obscure, but this works:
7z u -up1q0r2x2y2z1w2 myArchiveFile.7z dirToZip
(I found documentation for these 7z command-line options here: https://www.scottklement.com/p7zip/MANUAL/switches/update.htm. I don't know why it's so hard to find this documentation...).
If, for some reason, you don't want the compression provided by zip or 7z, there are ways to disable that too, so zip or 7z just create a file container kind of like tar does.
In the end, though, I think you should just re-create the archive each time. I suspect that the time saved doing the kind of synchronization you ask for is probably small.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have a folder on my desktop that has around 2500 folders in it, each folder has multiple files in them that are zipped, I can unzip them by manually clicking on them, is there a way to do this automatically through terminal?
find ./ -name \*.zip -exec unzip {} \; maybe?
you can try the unzip command, but i think it only works with zip/tar files.
http://www.lifewithtech.net/apple/tip-unzip-multiple-files-into-a-single-directory-in-mac-osx/
http://magma.maths.usyd.edu.au/magma/faq/extract
or if you have the app The Unarchiver:
you can use the open command.
cd to your folder and use:
$ open */*.rar
this should extract all rar files in all sub-folders, according to your Unarchiver setup into a new folder or in the same folder.
Hope this helps.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Here are the steps I am doing again and again, and I was wondering if I can write a script which does this.
I have two local accounts:
thrust
hduser
Now, I am writing Java code in Eclipse in my thrust account.
After the code runs satisfactorily, I do:
mvn clean
cp -r /home/thrust/projectA -r /tmp/
su - hduser
cp -r /tmp/projectA /home/hduser/
cd /home/hduser/projectA
mvn package
Is there a way I can automate all these steps?
Or is there a way I can write code on this thrust account and the code automatically syncs with the hduser account?
Given that you are writing code (and you are doing it "again and again"), it seems you should be using a revision control system (like Subversion or Git), either with a local repository or with a hosting service (for example: GitHub or Bitbucket).
If you don't want to use an RCS, you can create a shell script to automate what you are already doing, as suggested by #iamnotmaynard.
Also, take a look at rsync or ssh. They can help you to copy files from one user to another more easily (rsync can also help you to keep these files synchronized).
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm trying to create a directory in a shell script:
mkdir -p DirName
but I always get the same error:
cannot create directory `/DirName': Permission denied
If I run the same command directly from the shell instead of using the scripts, that works perfectly.
any idea?
Thank you! :)
If you're going to use the -p option, you need to specify the full path
mkdir -p /some/path/here/DirName
I suggest listing the full path (If you plan on your shell script to change locations).
If your shell script isn't going to change locations (you're not going to move it somewhere else later), I'd use:
mkdir ./DirName
These should all behave similarly to you creating the directory in the shell.
You are trying to create a directory in the root of the filesystem (/DirName) instead of in the current directory (Dirname or ./Dirname). You don't have access to write to the root.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
What's the easiest command to use to search for a directory or file containing "abc" in it?
You can use find command:
find . -name "*abc*"
The previous command will search for any file or directory containing "abc" within the current directory (and all its subdirectories).
The locate command
locate "*abc*"
also works in addition to the find command already mentioned.
Note, this works quickly by querying a database created/updated/maintained by the updatedb command which usually runs regularly as a cron job. This means however that if the file was just created you may not find it until updatedb runs again (or you run it yourself assuming you have sudo priviledges). In those circumstances find might be your best bet, while slower, as it searches the directories you specify right at that moment.
This should do it
find / -iname "*abc*"