command-line

perl - replace every nth (and multiples) occurrences of a character with another character

♀尐吖头ヾ 提交于 2020-01-21 12:23:35
问题 Does anyone know any unix commands/perl script that would insert a specific character (that can be entered as either hex (ie 7C) or as the actual character (ie |)) in the position of the nth recurring occurence of a specific character. ie perl script.pl "," 3 "|" data.txt would replace every 3rd,6th,9th...etc comma with a pipe. So if data.txt had the following before the script was run: fd,3232,gfd67gf, peas,989767,jkdfnfgjhf, dhdhjsk,267,ujfdsy,fuyds,637296,ldosi,fduy, 873,fuisouyd,try save

perl - replace every nth (and multiples) occurrences of a character with another character

佐手、 提交于 2020-01-21 12:23:11
问题 Does anyone know any unix commands/perl script that would insert a specific character (that can be entered as either hex (ie 7C) or as the actual character (ie |)) in the position of the nth recurring occurence of a specific character. ie perl script.pl "," 3 "|" data.txt would replace every 3rd,6th,9th...etc comma with a pipe. So if data.txt had the following before the script was run: fd,3232,gfd67gf, peas,989767,jkdfnfgjhf, dhdhjsk,267,ujfdsy,fuyds,637296,ldosi,fduy, 873,fuisouyd,try save

What is $opt variable for command line parameter in bash

别说谁变了你拦得住时间么 提交于 2020-01-21 12:16:27
问题 I have below bash script, I am a bit confuse about what is $opt meaning. and I do not find detail information about it after search. test.sh: echo "opt:" $opt for opt; do echo $opt done output: ./test.sh -a -b c opt: -a -b c 回答1: From the bash(1) man page: for name [ [ in [ word ... ] ] ; ] do list ; done The list of words following in is expanded, generating a list of items. The variable name is set to each element of this list in turn, and list is executed each time. If the in word is omit‐

Running .jar file - Double click vs. command line execution

雨燕双飞 提交于 2020-01-21 10:04:46
问题 I have a java desktop application that contains the following code: JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); System.out.println("check1"); int intResult = compiler.run(System.in, System.out, foutErrorFile, strvalidatePath); System.out.println("check2"); When I run the corresponding .jar file of this application by executing "java -jar name.jar", both check1 and check2 gets printed and app works fine. But when i try to run the jar by double clicking the .jar file, I found

How to get chrome version using command prompt in windows

╄→尐↘猪︶ㄣ 提交于 2020-01-21 06:46:25
问题 Is it possible to get version installed chrome version using command prompt in windows? Tried, "C:\Program Files\Google\Chrome\Application\chrome.exe" -version "C:\Program Files\Google\Chrome\Application\chrome.exe" --version "C:\Program Files\Google\Chrome\Application\chrome.exe" -product-version "C:\Program Files\Google\Chrome\Application\chrome.exe" --product-version When i do that, a browser instance is opening. What flag should I be using to get the version. I am using Windows 7. Google

Need a way to check status of Windows service programmatically

╄→尐↘猪︶ㄣ 提交于 2020-01-21 04:25:06
问题 Here is the situation: I have been called upon to work with InstallAnywhere 8, a Java-based installer IDE, of sorts, that allows starting and stopping of windows services, but has no built-in method to query their states. Fortunately, it allows you to create custom actions in Java which can be called at any time during the installation process (by way of what I consider to be a rather convoluted API). I just need something that will tell me if a specific service is started or stopped. The IDE

run two commands in one windows cmd line, one command is SET command

不羁岁月 提交于 2020-01-21 03:16:09
问题 [purpose] This simple command sequence runs expected in the Windows' CMD shell: dir & echo hello will list the files and directories and echo the string. However, the following command sequence does not run as expected (at least by me): C:\Users\Administrator>set name=value & echo %name% %name% C:\Users\Administrator>echo %name% value C:\Users\Administrator> As we can see, the first echo cannot get the environment. Could you help to comment? Any comment will be appreciated! PS: OS:Windows 7

Multiple fork() Concurrency

萝らか妹 提交于 2020-01-20 19:42:06
问题 How do you use the fork() command in such a way that you can spawn 10 processes and have them do a small task concurrently. Concurrent is the operative word, many places that show how to use fork only use one call to fork() in their demos. I thought you would use some kind of for loop but i tried and it seems in my tests that the fork()'s are spawning a new process, doing work, then spawning a new process. So they appear to be running sequentially but how can I fork concurrently and have 10

How to make IntelliJ prompt me for command line arguments

╄→гoц情女王★ 提交于 2020-01-20 03:50:26
问题 In Eclipse, you can provide the program argument ${string_prompt} in your run configuration to have it prompt for the command line arguments. Is there a way to do this in IntelliJ? 回答1: Edit: This may be a bug in IDEA, the solution that I first posted (you can see it below) causes Intellij to hang after entering parameter. I couldn't come up with a solution to this, but here's a little trick: you can scroll to the very bottom of Run/Debug configuration screen and in "Before launch" section

Command line Arduino compiling and uploading?

家住魔仙堡 提交于 2020-01-19 23:55:21
问题 How do I compile and upload Arduino sketches from the command line on Mac and Linux? I've installed the Arduino programming environment. Are there some sample makefiles anywhere? 回答1: Compiling and uploading sketches (as apposed to C/C++ sources) on the command line (on Windows, Mac, and Linux) is supported directly via flags to the arduino executable since 1.5.0. An ino can be compiled and uploaded with arduino --upload [sketch.ino] Documentation 回答2: There is a command-line Arduino toolkit