Questions tagged [string]
String manipulation: extracting a part of a string, text replacement, formatting to a given width, etc.
808 questions
2
votes
1
answer
75
views
Want to search for a every paragraph that has a certain string and return some string from that paragraph
/* ----------------- WANT TO RETURN1 ----------------- */
machine: some value
server: WANT TO RETURN1
owner: some value
notification: some value
informatica: some value
sap:...
1
vote
6
answers
679
views
Change a double quote into a single quote with gnu sed when the quotes come before and after a parenthesis?
I'm using Debian 12 bookworm, gnu sed. I have this
"Hello1"
"('41-Z', 5001, 'A6')"
"'Hello2'"
"('42-Z', 5002, 'A7')"
'Hello3'
"('43-Z', 5003, 'A8')"
...
6
votes
2
answers
490
views
Can I use grep or strings to find the previous atime of a file still present on my btrfs?
The metadata of this file which resides on my HDD is written by CoW, therefore can I look for it just by using grep or strings, and the filename?
0
votes
3
answers
105
views
Making each word in a text file an item in a bash array
I have a string of text and spaces which looks like this:
macOS windows arch-linux ubuntu_linux
I want to append each item (with whitespace denoting a break between items) to a bash array. How do I ...
2
votes
1
answer
387
views
How can I take a sub-array in bash of the first N elements of a string array with elements containing spaces?
This question is similar to this one but it differs from it:
Consider this array with string elements which may contain spaces:
a@W:$ arr=("eins" "zwei" "eins plus zwei" &...
-1
votes
2
answers
79
views
Split string with 0-2 / (or determine there's none) (Bash)
Update: Up to 2 "/" in the string.
String structure is either:
Character set name/LF
Character set name/CRLF
Character set name/CRLF/(unknown purpose, likely a number)
Character set name
...
0
votes
2
answers
196
views
How to check value inside a file using bash?
I'm trying to check if the value inside a file is "0".
COUNT_EXECUTION=$(< /tmp/count)
if [ "$COUNT_EXECUTION" == "0" ]; then
echo "Try restart service."
...
0
votes
3
answers
295
views
How to edit a string matching a pattern in a specific field on the condition another string is not present on the same line
I need to edit the string "NA" to "Na" only if it is in the 6th field of a file. I can currently achieve this with:
awk '{gsub("NA","Na",$6)}1' $filename
...
0
votes
3
answers
383
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 ...
0
votes
1
answer
100
views
Problem matching new terminal window ID with xdotool in Bash
I have a script that kicks off a new terminal window that I want to move to a specific position on the left terminal using xdotool.
After kicking off the terminal I run
xdotool search --class gnome-...
2
votes
1
answer
320
views
Joining 'fish shell' arguments into a single string with spaces
Sorry, this question is already answered for 'bash' here:
Joining bash arguments into single string with spaces.
in Fish, using "'$*'" leads to this error:
$* is not supported. In fish, ...
0
votes
1
answer
60
views
What does the line ($eachJOBID = $eachScriptNoPath) =~ s/\.csh// ; do?
This line I have in my code cuts the .csh from a string and returns the rest of it. Can someone explain what each part of it does?
($eachJOBID = $eachScriptNoPath) =~ s/\.csh// ;
2
votes
5
answers
529
views
How to remove duplicate slashes from path to a file?
I have a path to a file that has duplicate slashes which would like to simplify.
For example, if I have the following:
/opt//bin//executable
I would like to get:
/opt/bin/executable
-1
votes
1
answer
57
views
I can't grep some inputrc string
bind -p |grep -E "\\e.\":" work
but
bind -p |grep -E "\\e\\C-.\":" don't work
I tried a lot of combination
1
vote
1
answer
96
views
GNU parallel: how to call exported bash function with empty string argument?
Scenario:
$ process(){ echo "[$1] [$2] [$3]" ; } ; export -f process
$ process "x" "" "a.txt"
[x] [] [a.txt]
Here we see that the 2nd argument is empty string ...