Skip to content
Advertisement

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 using loops? Answer Use nested loops:

How to limit a search of a directory with “find” command?

I am trying to make a Bash script that would create symlinks to directories that have a “target” subdirectory. I use “find” command to search for the “target” directories and put the filepaths to array. The array is looped through and symbolic links are made to directories. My issue is that the depth of the directory structure is unknown and

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 back (return) the following info from the container:

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 ‘find’

How to make the bash script work with one command after another?

I have a bash script like below. First it will take sorted.bam files as input and use “stringtie” tool give each sample gtf as output. Then path for each sample gtf will be given into mergelist.txt. and then use “stringtie merge” on them to get “stringtie_merged.gtf”. I totally have 40 sorted.bam files. I separated the commands with ; After running

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 normal ASCII range. Try: How it works:

How to get the process status only with “R” in linux?

–Need to get the status of the background running script. Initially, I ran the script and terminated it turned to stat “T” further, running the same script but while grep getting the script with stat “T”and “R” Here, how to get the process with only “R”. here is the command used ps aux | grep test.sh | grep -v grep

Advertisement