utilities

MySQL Utilities - ~/.my.cnf option file

无人久伴 提交于 2019-11-27 17:30:39
I am trying to use 2 of the mysql utilities, mysqldiff and mysqldbcompare and want to avoid putting my password on the command line Is it possible to use an option file to specify the password for my DB connection to prevent me having to specify the password? This is the sort of command that I currently have... /usr/share/mysql-workbench/python/mysqldiff --server1=root@localhost --server2=root@localhost --difftype=sql db1:db2 I also have a file at ~/.my.cnf that has "600" permissions and contains the following.. [client] user=root password=mypassword When I connect via the command line to

Unix command to prepend text to a file

邮差的信 提交于 2019-11-27 17:16:29
Is there a Unix command to prepend some string data to a text file? Something like: prepend "to be prepended" text.txt Prince John Wesley sed -i.old '1s;^;to be prepended;' inFile -i writes the change in place and take a backup if any extension is given. (In this case, .old ) 1s;^;to be prepended; substitutes the beginning of the first line by the given replacement string, using ; as a command delimiter. shime printf '%s\n%s\n' "to be prepended" "$(cat text.txt)" >text.txt Process Substitution I'm surprised no one mentioned this. cat <(echo "before") text.txt > newfile.txt which is arguably

Checking if a number is an Integer in Java

二次信任 提交于 2019-11-27 15:39:08
问题 Is there any method or quick way to check whether a number is an Integer (belongs to Z field) in Java? I thought of maybe subtracting it from the rounded number, but I didn't find any method that will help me with this. Where should I check? Integer Api? 回答1: Quick and dirty... if (x == (int)x) { ... } edit: This is assuming x is already in some other numeric form. If you're dealing with strings, look into Integer.parseInt . 回答2: One example more :) double a = 1.00 if(floor(a) == a) { // a is

Command line tool to delete folder with a specified name recursively in Windows?

瘦欲@ 提交于 2019-11-27 02:47:30
I want to delete every "_svn" in every folder and subfolder... For example c:\ proyect1 _svn images _svn banner _svn buttons _svn Then I run something like rm-recurse c:\proyect1 _svn And I should get: c:\ proyect1 images banner buttons The ideal thing would be a tiny stand-alone EXE or something like that. -- Thanks Grant, as soon as I posted the question I saw SVN documentation about the SVN export command, but I also want to delete the _vti_* folders stuff Visual Studio creates, so I'll also explore the for solution. Similar to BlackTigerX's "for", I was going to suggest for /d /r . %d in (

Get length of longest line in a file

非 Y 不嫁゛ 提交于 2019-11-26 19:31:34
I'm looking for a simple way to find the length of the longest line in a file. Ideally, it would be a simple bash shell command instead of a script. Using wc (GNU coreutils) 7.4: wc -L filename gives: 101 filename Pale Blue Dot awk '{print length, $0}' Input_file |sort -nr|head -1 For reference : Finding the longest line in a file awk '{ if (length($0) > max) {max = length($0); maxline = $0} } END { print maxline }' YOURFILE Just for fun and educational purpose, the pure POSIX shell solution , without useless use of cat and no forking to external commands. Takes filename as first argument: #!

Unix command to prepend text to a file

烈酒焚心 提交于 2019-11-26 11:57:15
问题 Is there a Unix command to prepend some string data to a text file? Something like: prepend \"to be prepended\" text.txt 回答1: sed -i.old '1s;^;to be prepended;' inFile -i writes the change in place and take a backup if any extension is given. (In this case, .old ) 1s;^;to be prepended; substitutes the beginning of the first line by the given replacement string, using ; as a command delimiter. 回答2: printf '%s\n%s\n' "to be prepended" "$(cat text.txt)" >text.txt 回答3: Process Substitution I'm

Command line command to auto-kill a command after a certain amount of time

末鹿安然 提交于 2019-11-26 10:22:05
I'd like to automatically kill a command after a certain amount of time. I have in mind an interface like this: % constrain 300 ./foo args Which would run "./foo" with "args" but automatically kill it if it's still running after 5 minutes. It might be useful to generalize the idea to other constraints, such as autokilling a process if it uses too much memory. Are there any existing tools that do that, or has anyone written such a thing? ADDED: Jonathan's solution is precisely what I had in mind and it works like a charm on linux, but I can't get it to work on Mac OSX. I got rid of the SIGRTMIN

Command line tool to delete folder with a specified name recursively in Windows?

喜夏-厌秋 提交于 2019-11-26 10:15:39
问题 I want to delete every \"_svn\" in every folder and subfolder... For example c:\\ proyect1 _svn images _svn banner _svn buttons _svn Then I run something like rm-recurse c:\\proyect1 _svn And I should get: c:\\ proyect1 images banner buttons The ideal thing would be a tiny stand-alone EXE or something like that. -- Thanks Grant, as soon as I posted the question I saw SVN documentation about the SVN export command, but I also want to delete the _vti_* folders stuff Visual Studio creates, so I\

How to convert map to url query string?

一笑奈何 提交于 2019-11-26 08:07:47
问题 Do you know of any utility class/library, that can convert Map into URL-friendly query string? Example: I have a map: \"param1\"=12, \"param2\"=\"cat\" I want to get: param1=12&param2=cat final output relativeUrl+param1=12&param2=cat 回答1: The most robust one I saw off-the-shelf is the URLEncodedUtils class from Apache Http Compoments (HttpClient 4.0). The method URLEncodedUtils.format() is what you need. It doesn't use map so you can have duplicate parameter names, like, a=1&a=2&b=3 Not that

Longest line in a file

你离开我真会死。 提交于 2019-11-26 06:58:46
问题 I\'m looking for a simple way to find the length of the longest line in a file. Ideally, it would be a simple bash shell command instead of a script. 回答1: Using wc (GNU coreutils) 7.4: wc -L filename gives: 101 filename 回答2: awk '{print length, $0}' Input_file |sort -nr|head -1 For reference : Finding the longest line in a file 回答3: awk '{ if (length($0) > max) {max = length($0); maxline = $0} } END { print maxline }' YOURFILE 回答4: Just for fun and educational purpose, the pure POSIX shell