Skip to content

Tag: bash

Decrease the number of calls

I have arraylist of filenames (java) and I want to delete these files using rm but it is time consuming can I do batching using xargs or something else which can help to delete files faster. Answer Don’t use rm. Use Java. As others have pointed out, spawning a process is much slower than doing it in your program. Also,

Program to find from where the program is called

The requirement is very simple, I want to write a simple hello world program or anything so the program knows about its execution parent. For eg. Since I am from a Java background I will give a Java example. I want to write a jar that runs and outputs the following: Running from command line: but when running from

Inconsisent S3 parameter validation error when running bash script in Ubuntu WSL

I’m experimenting with AWS Lambda by following along with the instructions here: Part of the setup instructions require running this script ( When I run the script in WSL I get a parameter validation error: However, when I manually run the last two lines of the file with the debug output it works correctly: Why does this fail when

Double backslash under Linux bash

In the Linux bash to identify a Windows folder I have to use double backslash for example “java -jar myjar.jar C:\Users\username” while in the Windows command prompt does not need, just “java -jar myjar.jar C:Usersusername”, is it normal? Answer Yes, the backslash is used for newlines and special characters in bash. But since Windows uses backslashes in file paths, it

How to run sed command from java code

I’m probably missing something, but I’m trying to run commandline from a java The code is as following: String command = “sed -i ‘s/\^@\^/\|/g’ /tmp/part-00000-00000”; ProcessBuilder pb = new …