Skip to main content

All Questions

Tagged with
0 votes
3 answers
213 views

Convert json data to comma separated string

I have a json object that has an unknown number of variables, like this: { "var1": 123, "var2": 456, "var3": 789 } How can I automatically convert it to form ...
teeeeee's user avatar
  • 293
0 votes
1 answer
537 views

bash: string variable contains asterisk. how to use this variable for searching etc with grep, sed?

Have a nice day I have got text file (zz.txt): Chemical name 3-Aminopropane-1-sulphonic acid Synonym(s) -- Homotaurine * Tramiprosate -- Chemical name Common name and synonyms ... I have variable s=&...
Alex Den's user avatar
0 votes
2 answers
569 views

Use SED to replace part of a current variable with user input variable

I'm trying to replace only part of the existing variable with a new user input variable as below: #Current Variable: gdbName=Test.MY.DOMAIN.COM <--I need to replace the "Test" (This can ...
Ali's user avatar
  • 123
-4 votes
2 answers
427 views

Is it possible for any shell to interpret a string with decimal point as a number (int, float)?

This idea came to me with recent updates to Visual Studio Code, in which I usually shellcheck my code automatically as well. This is what I see, so you can get the idea: This question is very simple ...
Vlastimil Burián's user avatar
0 votes
1 answer
953 views

Why echo is printing string variables before additional text that have been merged with it?

I have code in bash for making latex file and in this fragment I want to make a table in a loop: while IFS= read -r line; do if [[ "$line" == *"comment"* ]]; then ...
Karolina Pomian's user avatar
0 votes
1 answer
42 views

find cannot do on having space within string variable for -path or -iregex or etc

Cannot have space within string variable for -path or -iregex find's option. This input '/home/demo.*/\.config/File System/.*t$' is fed on: read i m="-iregex $i" find ~ $m won't work as it ...
user avatar
1 vote
1 answer
78 views

Using a variable within a string

I'm stuck on a problem. I am a biologist who uses linux for automation so I don't have the best programming background and would appreciate your help. I have a large text file, containing several ...
wiiman3893's user avatar
2 votes
2 answers
1k views

Search for a String in a file and save the string after it to a variable

Example: Lets say this is in a file: AB: Test CD: Testing EF: Rest I want a script to search for CD and save "Testing" into a variable. I've tried something with awk but somehow I'm not making any ...
Andehake's user avatar
0 votes
1 answer
2k views

How to pass a multiword string as argument in Linux [duplicate]

I am trying to pass a multiword argument in a function an echo the result in a simple fashion. Currently I am doing this: function myFunction { multiWordString="" for ((i=3; i<=$#; i++...
Diagathe Josué's user avatar
3 votes
1 answer
4k views

Bash: How can i remove characters from a string until i hit a specific character

Basically, I'm trying to make a program that at one point needs to store coordinates. There is one part of the program where I need to separate one string into two so I an able to preform math on the ...
TheRedStormer's user avatar
1 vote
2 answers
323 views

Bash Split Variable into 3 Variables based off Delimiters?

Trying to split a string var with the following pattern: TestString="Artical Title Here (ClassYear) [Author]" I was able to get the title into a Var using cut as such: ATH="$(cut -d'(' -f1 <&...
user354662's user avatar
-1 votes
2 answers
991 views

Bash String Manipulation and Assignment

How can I manipulate a string and then assign it to a variable? This string manipulation works as I want: echo ${dir:2:5} | sed 's/[.]$//'; but: var x = ${dir:2:5} | sed 's/[.]$//'; and x = ${dir:...
user3783243's user avatar
4 votes
1 answer
2k views

Does one string contain another in fish shell?

I am working on my fish.config for using the fish shell. I am trying to compare strings using bash syntax but fish doesn't accept the syntax. There is clearly another way to do it. Any suggestions ...
deanshanahan's user avatar
13 votes
2 answers
2k views

What's the purpose of adding a prefix on both sides of a shell variable comparison to a string literal?

I have encountered comparisions of variables to string literals multiple times over the years which had one character prefixing the variable and the literal, e.g. if [ "x$A" = "xtrue" ]; then in ...
Kalle Richter's user avatar
2 votes
2 answers
7k views

How to filter a string against the characters from a variable?

I am trying to remove special characters (by passing them as a variable) from a string variable below command able to remove single characters not multiple? string=#@$AAA%* a=#$@%* #...
Harish a's user avatar

15 30 50 per page