Skip to content

Tag: arrays

Sorting an array of dates in bash

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:

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…

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 …

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…

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