Bash sed: Replace first occurrence of string that is alphabetically lower [closed] - bash

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 days ago.
Improve this question
I'd like to edit a already sorted file by inserting a new line at the correct point.
I'd like to point out that I can not sort the file after just echoing the new line in there since a lot of lines at the bottom of the file are in fact not sorted correctly but should stay that way.
So I was thinking is there an option to use sed or any other command to go through the file line by line and find the first line that is alphabetically lower than my insertion and just insert it there. Maybe awk can do this better?
Thank you very much
Example:
I want to insert A123
Into
A126
A124
A121
A120
So that the output will be
A126
A124
A123
A121
A120

Related

bash: Parse multiple arrays from multiple config files and write to one file [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 days ago.
Improve this question
Have multiple arrays like below in a multiple config files (abc1.conf, abc2.conf etc..)
which i want to consolidate into one file. So essentially take all CALCS and LOOPS form all config files and generate one config file with all arrays. Can anyone help out here
ex. abc1.conf contains the below
CALCS=( SUM CASES VALUE )
LOOPS=( SERVICE INSERT )
edit: filter out any duplicates if encountered in CALCS and LOOPS, so essentially only save unique values

How do I extract particular name from a file name in shell [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 months ago.
Improve this question
In shell scripting Suppose I have a file name called aaa_djdidm_cjcjcj_20220602.txt
I only want the name except the date.
Expected result - aaa_djdidm_cjcjcj
If you want to remove the part after the last _:
NAME="aaa_djdidm_cjcjcj_20220602.txt"
NEW_NAME=${NAME%_*}
The % operator is useful do remove the motif (here _*) of a named parameter (here NAME)

Cutting columns in many files - Bash - how do I save the results in different files? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I'm writing a script that would allow me cut columns number 2, 4, 5... in many files.
I know that I have to use awk to print only required columns. But how do I save the results in different files? What do I write after > ?
with gawk you can use FILENAME variable, and in your awk codes, redirect the required columns to FILENAME"_new" for example.
awk '{... ;print $2,$4,$5> FILENAME"_new"}' *.csv
You may want to add close(FILENAME"_new") if you have many files.

how to read a csv file which have comma in between the values in Informatica or talend tools? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have an input file where I have values like "Bengaluru","New,Delhi","New,York" and I want to read this data as Bengaluru,New Delhi,New York : commas inside the double quotes should not be evaluated as a separator : "New,Delhi" is evaluated as "New Delhi" and not separated in two items ("New" and "Delhi")
In Informatica you can specify the text qualifier as double quotes in source definition. That would give you the expected values.

Need bash script, that takes first line of a file, and then creates new directories out of words that have been taken [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Need bash script, that takes first line of a file, and then creates new directories out of words that have been taken. The file, that will be checked for first line has to be entered from command line(putty) as well as the directory where u will create those new directories
Can you please guys help me? Im thinking, that at first i have to take the first line of the file(i solved this part). But how do i make new directories with each word that i take from first line? Do I have to make cycle?
read reads a line, mkdir creates the directories.
read dirs < file
mkdir $dirs

Resources