All Questions
51 questions
0
votes
3
answers
88
views
Need to make multiple multiline replacements in file
I have a file with multiple "paragraphs" like this:
<type>TRANS</type>
<attributes/>
<specification_method>rep_name</specification_method>
<trans_object_id/&...
4
votes
4
answers
1k
views
Can I extract complete dates from file with grep command?
I need help using grep to extract a zoned date time from a file on a Linux system.
Source file is a XML with the data below:
<item start="20231010073000 +0100" stop="20231010100000 +...
0
votes
1
answer
221
views
Read subdirectory names and split into subdirectories based on dir name
This is probably really simple but I'm ox-hilling it for the better part of the day.
Problem:
I have several folders coming out of an app that I need to get into sub-folders. I'm going with separators ...
5
votes
5
answers
10k
views
Finding the line number of first occurrence of a text in bash script
I need to find out what is the line number of first occurrence of a given search string that should be in the start of a line in a text file and store it in a variable in my bash script. For example I ...
1
vote
2
answers
324
views
Extract field and number of occurrences per line
I have this file:
John Green', 'Age: 32', 'State: New York', 'Total cars: 2', 'Manufacter: General Motor', 'Model: Pontiac', 'Year: 2000', 'Manufacter: Ford Motor', 'Model: Endeavour', 'Year: 2010
...
-2
votes
4
answers
360
views
how to grab text after newline
assume this:
This is the only text I'M showing. The remaining text has more data[not showing], the problem. The text is semi-clean, full of whitespace, tabs, Unicode, isn't clean and has to be like ...
0
votes
3
answers
565
views
Search for pattern and create file with the same name
Here's a simple line of my usage:
grep -i '"location_country":"country name"' file.txt >> sample.txt
I'm searching a large file with multiple countries and what I would like ...
0
votes
1
answer
2k
views
using "grep", to match a list of IDs in a file to match with another file
I have been using various formats suggested here on the forum like this one:
grep -f file1.txt file2.txt > ouput.txt
file1.txt contains a list of IDs in one column e.g.:
15002345234
15001234214
...
2
votes
2
answers
74
views
Printing all lines matching a string and a set number of lines after that string
I want to extract relevant data of a traffic junction and it's connections from a log file. Example log:
SCN DD1251 At Glasgow Road - Kilbowie Road
Modified ...
2
votes
1
answer
764
views
How to grep certain interface block in Cisco IOS configuration with specific criteria?
This is sample of network interface configuration in Cisco IOS. Let's name it as cisco.txt.
!
interface FastEthernet0/1
shutdown
!
interface FastEthernet0/2
switchport access vlan 20
!
interface ...
6
votes
5
answers
6k
views
group and count by a regex
I have dozens of values in a file such as
(1608926678.237962) vcan0 123#0000000158
(1608926678.251533) vcan0 456#0000000186
I want to count how many of each there are based on the numbers before the ...
1
vote
3
answers
2k
views
Set multiple variables to different fields of awk output
I have a large set of variable initializations that I think could be greatly reduced. The file below being parsed:
-------------------- ACL Stats Per Interface ----------------------...
2
votes
2
answers
57
views
How to validate a line if followed by a specifc line?
On some our Linux servers we have the following files:
/etc/ambari-agent/conf/ambari-agent.ini
The files include the following example of lines:
; memory_threshold_soft_mb=400
; ...
2
votes
2
answers
189
views
copy numbers following specific characters
file1 contains:
SS1 2.979621e-01 3.022140e-02 4.273952e-05 0.107 0.223
Set 1: err.est. 7.72199e-05 a 1 tau1 0.0816095 tau2 98.7691
I want to:
copy the number following SS1 in ...
3
votes
1
answer
15k
views
Find Duplicate/Repeated or Unique words spanning across multiple lines in a file
Problem
Is it possible to print repeated words that are not unique and spanning across multiple lines? not just unique words within singular lines.
Previous work
There's this question which solves ...