Social Icons


Featured Posts

Monday, August 4, 2014

Linux - Copy and follow symlinks

If you want to copy and follow symlinks, use these arguments:

cp -rfL source dest

Tuesday, November 12, 2013

EDI - Copy only specific transaction to a folder


Here is a simple tutorial how to copy only a specific functional group type of EDI transaction.

In my example I need to copy all the 997 ( Functional Acknowledgment) to a specific folder.

My folder hierachy is /myhome/source/folder/CLIENT / (job / folder-in / folder-out) / YEAR / MONTH / DAY / myfile

where myfile is a single ISA per file and could be gzipped.

1 - Extract all gzipped EDI files under folder-in and folder-outfind /myhome/source/folder -type f -iwholename *folder* -iwholename *.gz  -exec zgrep -l '^ISA' {} \; -exec gunzip {} \;

2 - Copy all the 997 to /home/MY_FOLDER (Where FA is the GS Transaction code of the 997)find /myhome/source/folder -type f -iwholename *folder* -exec pcregrep -Ml '^ISA.*GS.FA'  {} \; -exec cp -rf {} /home/MY_FOLDER/ \;

Wednesday, October 23, 2013

Split a big text file into many files


Suppose that we have a big text file with 2 000 000 lines and you want to split it in 1 000 files containing 20 000 lines each.

You only have one command to type!

split -l 20000 myfile.txt

You will get 1 000 files.

If you are on Windows, you just have to install Cygwin Terminal

Wednesday, October 2, 2013

Batch - Deleting all the files and directories under a root directory


With Windows 7, I need to delete all the files and subdirectory under a root directory.

I was able to achieve this task with theses two commands in a batch script


The first one deletes all the files and directory under MY_DIRECTORY but it deletes also the root directory. I recreate after the root directory.

It may not be the best way to achieve this but it works.

Sunday, September 29, 2013

java.lang.NoSuchMethodError: antlr.collections.AST.getLine()

After adding Velocity to my Spring Web Application, I'm getting this error:

29.09.2013 22:44:26  WARN ( - Execution of JMS message listener failed, and no ErrorHandler has been set.
java.lang.NoSuchMethodError: antlr.collections.AST.getLine()I


The error is due by the conflicts between two differents version of "antlr". You need to exclude the version from velocity-tool.

So add the following exclusion to the velocity-tools maven dependency.


Wednesday, September 25, 2013

Tar following symlinks


Suppose that we have to tar gzip a directory that contains two symlinks.




If you use the usual command tar -zcvf ROOT_DIRECTORY.tgz ROOT_DIRECTORY

You will get an archive that contains two symbolic links.


If you want to include the content of symbolic links, you need to add a "h" just after the "c",

The command is tar -zchvf ROOT_DIRECTORY.tgz ROOT_DIRECTORY

You will get the directory including all the files under the ROOT_DIRECTORY