Assuming /media/G and /media/E are 2 different shared folders mounted allready and you are now inside Linux in VBox then do
rsync -av --delete /media/G /media/E
alias ls='ls --color=never'
#!/bin/bash for file in *.png; do filename=${file%.*} convert "$filename.png" "$filename.eps" done
To change extension from .PNG to lowe case .png
#!/bin/bash for file in *.PNG; do f=${file%.*} mv "$f.PNG" "$f.png" done
grep -H -r "string I am searching for" *
This should also work
grep -H -r 'string I am searching for' *
also this
find . -type f -exec grep -l 'string' {} \;
find . -name "*.txt" -print0 | xargs -0 egrep 'string'
find . -name "*.txt" -exec egrep -l '^string' {} \;
find . -type f -print0 | xargs -0 grep -H 'documentclass'
find . -type f -name *.tex -print0 | xargs -0 grep -l 'documentclass'
This example looks for all png files in current folder and will make thumbnails (shrink) any image that has a width larger than say 200 pixels. The height of the image is adjusted so that aspect ratio remain the same as originally was.
Edit as needed
#!/bin/bash shopt -s nullglob FILES=*.png for file in $FILES do f=${file%.*} echo "file is $file and f is $f" convert "$f.png[200x>]" "$f"_thumb.png done
This example is as above except that the resizing is limited to enlarging the images to say 200 pixels. Edit as needed
Reference:
Can use the file command. But the ouptput has to be parsed. easier to use imageinfo
>sudo apt-get install imageinfo #install if needed >w=`imageinfo --width foo.png` >echo $w 81 >h=`imageinfo --height foo.png` >echo $h 24
Reference:
Useful trick to know
convert big.gif -coalesce coalesce.gif convert -size 200x100 coalesce.gif -resize 200x10 small.gif
reference: http://stackoverflow.com/questions/718491/resize-animated-gif-file-without-destroying-animation
Thanks to http://www.turnkeylinux.org/blog/png-vs-jpg
apt-get install imagemagick #one file convert -flatten -background white file.png file.jpg #batch for f in *.png; do n=$(echo $f|sed 's/.png/.jpg/'); convert -flatten -background white $f $n done
Make sure first the windows folder is added to shared folder in VBox settings for the VM. Then boot the VM. Now inside Linux create a mount point where to mount the shared folder to
>sudo mkdir /media/nabbasi >ls -l /media drwxr-xr-x 2 root root 4096 Jun 22 17:02 nabbasi >cd /media >sudo chown -hR me:me nabbasi >ls -l drwxr-xr-x 2 me me 4096 Jun 22 17:02 nabbasi
Now mount the shared folder, making sure it is owned by me
>sudo ./win_mount.sh >cat win_mount.sh mount -t vboxsf -o uid=1000,gid=1000 nabbasi /media/nabbasi
Thanks to http://www.torrent-invites.com/showthread.php?t=194756
This will change all permissions on all files and folder
chmod -R 0755 folder_name
This will change the file, backup is made to INPUT.txt.bak
sed -i.bak '/^#/d' INPUT.txt
the -I {} is the marker, which says the file name is {}
find . -type f -name INPUT.txt -print0 | xargs -0 -I {} sed -i.bak '/^#/d' {}
The above could also be done like this
find . -type f -name INPUT.txt -print0 | xargs -0 sed -i.bak '/^#/d'
But I found using explicit marker for the argument more clear. This is useful. If using a command that needs more than one argument, the marker is needed anyway, so might as well get used to using it. Marker can be anything. So this works also
find . -type f -name INPUT.txt -print0 | xargs -0 -I file sed -i.bak '/^#/d' file
tree -n -L 1 --charset nwildner prints one level only and this tree -n -i -L 1 -d . does not print indentation lines
see http://unix.stackexchange.com/questions/83593/copy-specific-file-type-keeping-the-folder-structure
ulimit -n to find the limit, and to increase it to say 2048, type ulimit -S -n 2048
Put this in a file foo.php and put it in the folder to unzip the file on the server and type the URL to this file
type unlimt -a to see all limits. To change open file limit, edit the file /etc/security/limits.conf as root and add these lines
* soft nofile 4096 * hard nofile 4096
I rebooted after this just in case (may be reboot is not needed). Now it works. When I do
>ulimit -n 4096
Reference: thanks to lornix answer
Use sudo -E env "PATH=$PATH" command. Reference http://superuser.com/questions/709515/command-not-found-when-using-sudo
find /tmp/ -depth -name "* *" -execdir rename 's/ /_/g' "{}" \;
Above is thanks to Dennis Williamson from http://stackoverflow.com/questions/2709458/bash-script-to-replace-spaces-in-file-names
Seems to work well.
tr -d '\015' < file.txt > new_file.txt
Just make sure not to use the same file above, else it will be wiped out.
or just do sudo apt-get install dos2unix and type dos2unix foo.txt it will overwrite the file ok.
Thanks to Avinash Raj, use this command rename 's/.*\s//' *.pdf see http://stackoverflow.com/questions/34469075/bulk-file-renaming-in-bash-to-remove-name-with-spaces-leaving-trailing-digits
Install sudo apt-get install djvulibre-bin. To convert multiple files, I wrote this small script
To convert one file, type dj2pdf file.djvu and to convert multiple files, type dj2pdf "*.djvu"
thanks to Anderson M. Gomes http://unix.stackexchange.com/questions/270071/how-to-delete-all-files-with-specific-extension-in-specific-named-folders-in-lar
Here is the code
An example,
Answers thanks to https://stackoverflow.com/questions/13032701/how-to-remove-folders-with-a-certain-name
Or
This will list all files in tree, showing date file changed with latest changed at bottom of listing shown.
Thanks to Keith Thompson at https://unix.stackexchange.com/questions/24509/how-to-print-the-longest-line-in-a-file
Use
This will change all folder names below where it is issued and changes any space in the name to underscore.
To just update a program to its latest without knowing the version number do, say want to update gfortran
sudo apt-get upgrade gfortran
To update the distribution do
sudo apt-get dist-upgrade
To start a command after some time, say 30 minutes do sleep 30m && ./my_script
To start a command after some time, say 2 hrs do sleep 2h && python ./script.py
The above can be canceled before the time elapses, and the command will not run.
This was very tricky. Here are the steps I did. This is on Linux Ubuntu as guest running inside the VMWare virtual machine with windows 7 as Host.
First I made sure shared folder is added when installing the guest OS in VMWare setup. Added "data" as my shared folder name.
After booting into Linux, did (as user called "me")
sudo apt-get install open-vm-tools open-vm-tools-desktop open-vm-tools-dkms cd /mnt sudo mkdir -p /mnt/hgfs/data sudo sudo chown -hR me:me data #this sets me as owner. This is important vmhgfs-fuse .host:data /mnt/hgfs/data
Do NOT use sudo in the last command above. When I did that, I got permission error.
Make sure you are in vboxsers group
sudo usermod -a -G vboxusers <useruame>
logout and login. Now try to add USB 2.0 to VBox USB in settings of the window virtual machine. It should now be enabled.
in windows DOS, type
net use G: /delete
Where G: is say the network disk
Made my /home/me/data/ as shared folder in VBox setting. So shared folder shows as data then.
Booted VBox windows 7. Then in windows typed in DOS
Type net use G: \\vboxsvr\data
So now it shows in windows as derive G
sudo updatedb then locate file_name can also use find but locate is faster.
smbclient -L localhost if it asks for password, type it. It is then running.
lpstat -p
or do http://localhost:631/printers/ and select Printers from the menu. The above is CUSP interface.
convert 'moving_disk.gif[0]' moving_disk.png
Thanks to https://askubuntu.com/questions/22413/how-to-change-gnome-terminal-title type
PROMPT_COMMAND='echo -ne "\033]0;TITLE HERE\007"'
This will change the title in the terminal banner, normally located in the upper left corner.
To make the terminal title be the full path of the current folder, type
PROMPT_COMMAND='echo -ne "\033]0;$PWD\007"'
To make the terminal title be the last folder in full path of the current folder, type
PROMPT_COMMAND='echo -ne "\033]0;$(basename $(pwd))\007"'
Thanks to http://blog.floriancargoet.com/slow-down-or-speed-up-a-gif-with-imagemagick/
identify -verbose your.gif grep Delay| give current delay between each frame in 100’th of second. So it it say 50x100 then the delay is half second. To change the delay to one second between each frame do
convert -delay 100x100 your.gif your_slow.gif
So to make the time 0.25 second between each frame do
convert -delay 25x100 your.gif your_slow.gif
It looks like 6x100 is min time betweeb frames that browsers support. But this could depend on which browser.
use the command find . -type f -mmin -150 to find files that changed within 150 minutes ago. And the command find . -type f -mmin +150 to find files that changed longer than 150 minutes ago.