Linked Questions
39 questions linked to/from Replace one substring for another string in shell script
1 vote
1 answer
5k views
How to replace comma with character in Unix bash [duplicate]
I have the below string: "BBBB,AAAA" seperated with comma. I need to append .done with each value of the string. When i try below. It doesnot work. I try to replace , with .done but its doesnot ...
0 votes
2 answers
325 views
Setting a variable and utilizing sed [duplicate]
I've been trying to wrap my head around this for over an hour now and my searches haven't helped yield the answer. Trying to set a variable inside a bash script. This variable is taking variable-A ...
0 votes
1 answer
242 views
Replacing substring with other text in variable inside a bash script [duplicate]
I've been trying to write a bash script. A part of it is supposed to replace a part of a string with nothing. Here's what I'm trying to do $dbname=$1 $dbNameActual="${$dbname/.sql/}" date echo $...
-1 votes
1 answer
430 views
Making a bash c# compiler? [duplicate]
I want to start developing in c#, however I use Linux and VSCode for development and VSCode doesn't run the code due to some error that I can't find an answer to, so I decided with the help of this ...
0 votes
0 answers
335 views
to replace part of string in shell script [duplicate]
I have string /logoDown?path=logo/5402eca1b4a0e/Lighthouse.jpg&isLogo=1&fileType=jpg Now i want to replace word logo with sep/2014/09/03/past/ so the new string will become /logoDown?...
-1 votes
1 answer
171 views
Replace " by \" inside a string [duplicate]
How can I replace a " by \" inside a string using bash? For example: A txt-File contains text like: Banana "hallo" Apple "hey" This has to be converted into: Banana \"hallo\" Apple \"hey\" I tried ...
-1 votes
3 answers
82 views
Trouble swapping datestamps in a log file's name using Bash [duplicate]
I'm trying to swap the date in a log file's name using a bash script. I cannot seem to get the date's to play nice however. When I try to swap the dates using sed, the original date is still in the ...
1 vote
2 answers
54 views
Variable in variable string [duplicate]
When I do that: VAR1="My_ID" VAR2="/Path/to/some/resource/$VAR1/in/local/machine" echo $VAR2 then output is: /Path/to/some/resource/Special/My_ID/local/machine But when ID="...
0 votes
0 answers
47 views
Shell parameter expansion with file path - "No such directory" [duplicate]
I need to ensure a directory is always created lowercase, regardless of what the user inputs. Here's some sample inputs: ./1A_Internal/foo/bar/baz/ ./External/wizz/bang/baz/ ./Validated/bink/bank/...
272 votes
22 answers
221k views
Removing colors from output
I have some script that produces output with colors and I need to remove the ANSI codes. #!/bin/bash exec > >(tee log) # redirect the output to a file but keep it on stdout exec 2>&1 ...
164 votes
5 answers
548k views
Where is the php.ini file on a Linux/CentOS PC? [duplicate]
I can't find PHP.ini location on my server. I've checked all Stack Overflow answers but I can't find my php.ini location. I have Linux, Cent OS, zPanel. Last version of PHP. My computer: Linux Mint ...
128 votes
10 answers
129k views
Batch renaming files with Bash
How can Bash rename a series of packages to remove their version numbers? I've been toying around with both expr and %%, to no avail. Examples: Xft2-2.1.13.pkg becomes Xft2.pkg jasper-1.900.1.pkg ...
59 votes
5 answers
77k views
How to replace one character with two characters using tr
Can tr replace one character with two characters? I am trying to replace "~" with "~\n" but the output does not produce the newline. $ echo "asdlksad ~ adlkajsd ~ 12345" | tr "~" "~\n" asdlksad ~ ...
18 votes
6 answers
12k views
Git: Rename or move all files at once
I want to rename all erb files in my Git project to haml.(like index.html.erb to index.html.haml) If I rename each file, I have to type the following command more than thirty times. $ git mv app/...
15 votes
4 answers
31k views
Replace string in variable using Bash
I'd like to replace a string within a variable, e.g.: Test=Today, 12:34 I'd like to replace the "Today" within the variable Test with a Date variable I declared before. I tried using the ...