Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to group the information respectively with comma separator in the input?
    text
    copied!<p>My file name is myInfo.txt under the current directory: <code>DIR="$(pwd)";</code></p> <p>inside it has:</p> <pre><code>1000 at num 2049 28 2068100 1000 at num 2049 28 2623200 1000 at num 2049 28 2833000 1000 at num 2049 28 3499700 1000 at num 2051 28 2453500 1000 at num 2051 28 2969400 1000 at num 2051 28 3071300 1000 at num 2051 28 3838200 </code></pre> <p>Now I used the bash script sequentially: </p> <pre><code>DIR="$(pwd)"; array=(2049 2151); for k in "${array[@]}"; do grep "at num ${k}" myInfo.txt | cut -d' ' -f 6 &gt; ${DIR}/Info/nums/${k}.out done </code></pre> <p>and group the 6th column information in each row like <code>2068100 2623200......</code> into the file <code>2049.out</code> and <code>2051.out</code> respectively under the folder <code>${DIR}/Info/nums/</code></p> <p>My question is: Can I use comma separator like follows to get the same functionality as before:</p> <pre><code>for k in "${array[@]}"; do grep "at num ${k}" myInfo.txt | cut -d',' -f 6 &gt; ${DIR}/Info/nums/${k}.out done </code></pre> <p>I tried to re-generate the myInfo.txt to satisfy the above command:</p> <pre><code>1000,at num 2049,28,2068100 1000,at num 2049,28,2623200 1000,at num 2049,28,2833000 1000,at num 2049,28,3499700 1000,at num 2051 28,2453500 1000,at num 2051 28,2969400 1000,at num 2051 28,3071300 1000,at num 2051 28,3838200 </code></pre> <p>and tried to group the information same as before. But it seems that the <code>cut -d',' -f 6</code> cannot get the same functionality as <code>cut -d' ' -f 6</code>. </p> <p>I wonder if the "cut -d',' -f 6" is valid? If it is valid, which kind of format of information should I re-generate in the myInfo.txt file? Thank you. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload