Skip to main content

All Questions

Tagged with
2 votes
5 answers
617 views

match value2 in 2 files if value 1 is exact match

I have 2 files containing list. Column 1 is userIds & column 2 is associated values # cat file1 e3001 75 n5244 30 w1453 500 #cat file2 d1128 30 w1453 515 n5244 30 e3001 55 Things to consider. ...
Sollosa's user avatar
  • 1,983
1 vote
2 answers
3k views

Write values with embedded commas from arrays into CSV file using BASH

I am trying to write different arrays into a csv file ($file) columns. Each array has the same number of values. For example, arr1 and arr2 have 3 values each arr1=( 23 45 34 ) arr2=( "abc,d"...
Lilek3's user avatar
  • 11
0 votes
1 answer
995 views

Read csv from shell script and print the column header based on closest match to user input

I Have a csv file. It has multiple columns. I want to develop a shell script which prompts the use for a numerical value, find the closest match in the csv and print the header of the column. For ...
MO12's user avatar
  • 409
25 votes
5 answers
29k views

how to shift array value in bash

we want to build 6 mount point folders as example /data/sdb /data/sdc /data/sdd /data/sde /data/sdf /data/sdg so we wrote this simple bash script using array folder_mount_point_list="sdb sdc sdd sde ...
yael's user avatar
  • 13.9k
14 votes
8 answers
18k views

How to test if array elements are all equal in bash?

The following array represented the numbers of disks on each linux machines Each single array includes the number of disks on a linux machine. echo ${ARRAY_DISK_Quantity[*]} 4 4 4 4 2 4 4 4 what is ...
yael's user avatar
  • 13.9k
1 vote
2 answers
1k views

Using awk to process multiple files need to count occurance of variable after pattern. How can I stop array resetting after each file?

I want to count all occurances of any variable in parenthesis after patterns, for files in a directory that have a specific extension. Each file may contain the pattern on multiple records/line. So ...
BoRain's user avatar
  • 11
0 votes
3 answers
7k views

AWK Compare Column 1 from Two Files Print append column to third in output

Looking to compare the first column of two input files that have an identical format. The format looks like the following: FILE1: 0000abc5abc3 GR096 0000def5ae87 GR001 0000cab5aea3 GR001 ...
drfunkenstein's user avatar
0 votes
1 answer
2k views

How to store output of awk to array with empty string on null values? [duplicate]

I have a variable animals. animals=lion*tiger*elephant**cat***dog I just want to split by the delimiter * and store it into an array. Expected: animals[0]="lion" animals[1]="tiger" animals[2]="...
rajagopalx's user avatar
-1 votes
2 answers
626 views

How to sum many numbers inside 2D array using awk

I need to sum numbers located in a file like this one: column1 column2 column3 row1 a(1,1) a(1,2) a(1,3) row2 a(2,1) a(2,2) a(2,3) row3 a(3,1) a(3,2) a(3,3) row4 a(4,1) ...
alloppp's user avatar
  • 433
2 votes
1 answer
378 views

Bash script to summarize " last -a "

I would like to make a shell script such that it runs the " last -a " command and summarizes it's data in the form : userID : number of login sessions Host or ip1 - number of ...
DynamicQ's user avatar
1 vote
1 answer
6k views

Compare two Arrays in KSH and output the difference

I am not extremely familiar with KSH (Actually just started using it) and I am having problems with trying to create a script that will essentially compare two arrays that have been stored and then ...
Christopher Stanley's user avatar