All Questions
19 questions
2
votes
3
answers
86
views
Printing a specific section everytime search results are matched
I have a pretty basic text file on a Linux machine that has stuff like Chapters, Dialogues and References.
This is what it looks like
Chapter: 1 One: Birds and Trees
Birds are beautiful and trees ...
0
votes
2
answers
711
views
Insert all the lines of a file into another file between two patterns
file1 contents:
1111
2222
3333
4444
file2 contents:
[webservers]
[databases]
I want the file2 contents to look like: After adding all the lines, insert a new line.
[webservers]
1111
2222
3333
4444
[...
-1
votes
3
answers
326
views
Compare data from two files and update the 2nd file in Shell
I need to compare data from two files and based on the condition I need to update the 2nd file in Shell.
I have two set of files.
The first file contains data as
NUMBER,ID
748378,9508
473738,7892
...
1
vote
2
answers
90
views
Regexp to fix GPS data
I'm looking to fix GPS data in text file on Linux
Incorrect string model: 49:29:37N 005:28:39E
2or3digits:2or3digits:2or3digits(N|S) 2or3digits:2or3digits:2or3digits(E|W)
Correct string model: 49:29:...
0
votes
2
answers
885
views
column data type validation
I was trying to use an awk command to verify if a particular column is not matching with a regex (basically I am validating a column in a file with uniform format , if not I need to throw error)
...
0
votes
1
answer
904
views
How to use BASH variable for AWK filtering results
I have this script, I'm getting first letter of my directory name, and I wan't to get directory names that start with the same letter and write to textfile. The for loop is looping list of directory ...
0
votes
0
answers
311
views
Change DISPLAY to remote host
I would like to replace the IP in $DISPLAY to the remote host IP ($SSH_CLIENT or $SSH_CONNECTION)
$(echo $DISPLAY | sed -e "s/^[^:]*\(.*\)/$(echo $SSH_CLIENT | awk '{ print $1}')\1/")
I did ...
2
votes
2
answers
2k
views
How to print all the matched string using awk?
My inputs are something like:
["https://www.tesing.com/watch/80239279"],
["https://www.testing.com/watch/80240715?source=35"],
["https://www.testing.com/watch/80242619?trackId=254015180&tctx=0%...
0
votes
2
answers
165
views
bash + regular expression + capture java version [closed]
how to capture the jdk1.8.0_112 under /usr/jdk64
/usr/jdk64/jdk1.8.0_112/
while jdk1.8.0_112 is example
and could be any other version as
jdk1.7.0_112
jdk3.8.2_112
jdk1.8.0_117
jdk1.2.0_112
jdk2.7....
0
votes
2
answers
145
views
Changing two strings on same line matched by a regex
I have a number of variables in a .dat file that I automatically changed with a script. One of these files has a parameter, bar, that is arranged as such in a .dat file:
var1 var2 var3 foo bar
T ...
3
votes
1
answer
273
views
Text processing and exporting the content to an excel sheet
I am trying to process a text file that contains multiple entries, I am interested in the Data filed of the text which consists of Name, Id, Size and Page83 ID.
Command: show PhysicalDisk name='IBM (...
-1
votes
1
answer
111
views
Linux replace only user part in email pattern
I have users like below in many *sh scripts.
[email protected]
[email protected]
[email protected]
I want to replace any emails like above with [email protected] in linux.
Any idea will be appreciated ?
12
votes
3
answers
7k
views
How do you remove dot character from string without calling sed or awk again?
I have a file called hostlist.txt that contains text like this:
host1.mydomain.com
host2.mydomain.com
anotherhost
www.mydomain.com
login.mydomain.com
somehost
host3.mydomain.com
I have the following ...
1
vote
2
answers
4k
views
How can I use the environment variables inside a regular expression in awk?
#!/bin/sh
ALTER="1153"
NAME="aio"
for i in $(ps -eo pid,etime,comm | \
awk -v alt="$ALTER" -v name="$NAME" '$2~/[^0-alt]-/ && $3~/name/{print$1} ');
do
echo $i
done
2
votes
4
answers
2k
views
replace several comma out side one or more sets of curly braces and exception that in one or more sets of curly braces
In the text file I have multi records. Every record has multi column with comma separated, some column have one sets of curly brace and other have more than one curly brace.
I need:
If a comma is ...