Posted by
Notetaker
Friday, October 31, 2008
Thought I'd make a quick note about converting Windows files to Unix to remove the Carriage Returns from the file (which appear as ^M on the screen)
- Use dos2unix to create a new file without the ^M and then move it back over the original
$ dos2unix original_file.txt > original_file.txt.convert
$ mv original_file.txt.convert original_file.txt
- Use global search and replace in vi
:%s/^M//g
Note that the ^M above is done using CTRL-V CTRL-M
ie :%s/{CTRL-V}{CTRL-M}//g
Posted by
Notetaker
Thursday, July 17, 2008
Received the following error using tar on Solaris
tar: ././@LongLink: typeflag 'L' not recognized, converting to regular file
The solution is to use gtar instead of tar
/usr/sfw/bin/gtar
Posted by
Notetaker
Monday, April 21, 2008
Here is a good way to copy filesystems between servers using ssh and tar. It is a bit more reliable than scp especially in the area of symbolic links and permissions)
To copy all of the files and subdirectories in the current working directory to the directory /target, use:
tar cf - * | ( cd /target; tar xfp -)
To copy files to a remote server (ie sending the files)
cd /WHERE_THE_FILES_ARE
tar cf - FILES | ssh USER@TARGETHOST " cd /WHERE_YOU_WANT_THE_FILES; tar xvpf - "
To copy files from a remote server (ie receiving the files)
cd /WHERE_YOU_WANT_THE_FILES
ssh USER@TARGETHOST " cd /WHERE_THE_FILES_ARE; tar cf - FILES " | tar xvpf -
If you are copying large amounts of files and data you may wish to exclude the v flag (for verbose) in the tar command
All views on this blog are my own. All hints, tips and scripts should be run and tested on your development and test servers before attempting in production.