Skip to content

Tag: shell

Bash Create Directories/Subdirectories Using Two Lists

I would like to create a number of directories, each with a number of subdirectories based on two lists using Bash. Currently, the below code achieves this result: Yields Question: Is there a cleaner (non-single-line) way to achieve the same result, perhaps storing the two lists as arrays or variables and usi…

Return the ls -l output in docker container

So I have a docker container running which has a couple of folder/files inside. When I go inside the container I can see that they are: hostmachine$> docker exec -it testContainer bash testContainer@testContainer:~$ ls -l My question is: What script, how can I use it on my hostmachine that will: 1) Echo ba…

Print the two matched variables of awk in same line

This is the script which i wrote. The logs.txt consists of : In this the expected output is : But the output i am getting is : Can anyone rectify what is the error ? Answer I thinks this problem should be separated multiple problems. How do you think about below code? You can see what these code actually do

Pipes in Bash: One at a Time (Line by Line) or All at Once

First, I create 5 files In the following example, xargs seems to get all the results from find via the pipe all at once: In the following example, xargs seems to get all the results from find via the pipe one at a time (line by line): In the following example, xargs seems to get all the results from ‘fi…

How to validly add linux command option at the end?

I am wondering how I can add linux command option at the end without error. For example rm file1/ -r cp file1/ file2/ -r I experience some Linux cluster system can do it, bus others cannot. As searched for while, getopts command may help but I am not sure if getopts is best choice for that and (also not sure

How to find which column has special characters in a file

I would like to find out which column has special characters in a file For example, I have the data below: Desired output: I want the record number along with the column numbers that have special characters. Answer You didn’t define special character. I will assume that you mean anything outside of the …