I want to sort an array of dates. Example format: “2017-11-13_07-55-40” or Year-Month-Date_Hour-Minute-Second Answer Since your dates are already in YYYY-MM-DD-HH-MM-SS format, you can use numeric sort: To store output in another array use:
Tag: arrays
error while returning a char from a function in C [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 5 years ago. Improve this question hello, I am trying to pass and return a char in C but
How to “grep” in array with dot “.” precisely?
I’m trying to check if the user input $1 exist in an array. And here is my code: What I expect is only “aaa.bbb.ccc” or “ccc.ddd.aaa” can be found. However, in this case, like “aaa” or “ccc” can also pass the validation. Seems like the dot is not treated as part of the string. Should I use regex or other
JSON list (not object) to Bash array?
I’ve got a JSON list (the value of a key-value pair containing a list of items): [ “john”, “boris”, “joe”, “frank” ] How would I convert this to a bash array, so I can iterate over them? Answer Easy Case: Newline-Free Strings The simple approach is to use jq to transform your list into a line-per-item, and read that into
How to store command output into array in Ansible?
Essentially, I want to be able to handle “wildcard filenames” in Linux using ansible. In essence, this means using the ls command with part of a filename followed by an “*” so that it will list ONLY certain files. However, I cannot store the output properly in a variable as there will likely be more than one filename returned. Thus,
Adding value to an associative array named after a variable
I need your help with a bash >= 4 script I’m writing. I am retrieving some files from remote hosts to back them up. I have a for loop that iterate through the hosts and for each one tests connection and the start a function that retrieves the various files. My problem is that I need to know what gone
Segmentation fault caused by strb w1, [x22,x23] when x23 reaches a certain value
Encountered an interesting segmentation fault on strb w1, [x22,x23] instruction in ARMv8 Assembly code when x23 reaches a certain value (which is 635), when I’m not using bl write function. However, if I use bl instruction to call write function, the segmentation fault does not occur; but the program finishes with “… exited with code 02” in gdb or echo
move single string up into previous row
I have been trying to solve a problem for hours and haven’t found a solution. I am trying to reformat a text file that has been incorrectly parsed. The file format contains a list of names, starting with the last name first, and has a troublesome sole first name on one of the rows as below: I have tried dumping
Specify source line from csv when calling up/creating an array
I have a csv with data such as: I’ve written some code to turn each field into a variable, and also to create an array out of each word in field 2 (f2): My problem is now, because the file contains multiple lines I need some way of naming each array according to the line of data it was created
Bash Array Key from User Input
So I have a bash script which will scan a directory and run a function on a selected input. It seems that for some reason, the key is not setting from the array properly. What am I missing? All help is much appreciated! EDIT: As a side note, I can run the commands separately and get results. Here is the