All Questions
97
questions
2
votes
4
answers
637
views
Count lines ending in "*"
I have several files in a directory with this kind of content:
Wood *
Nails
Large Hammer *
Some names have a star after them, some don't. I have multiple files with such content. In each file a ...
0
votes
1
answer
1k
views
How to return true if string is found in a file using awk?
I have a file that looks like this:
xxxxx,aaaaaa,abab21323,ccccccc
I need a script that runs some command if a file contains a string given as a variable. If not, do some other commands.
This is my ...
-3
votes
2
answers
80
views
Grep first charcter from the string
10:30:01
10:35:01
There is a time in a format, where i want to grep:
Case1: 1 from 10
Case2: 3 from 30
Output as
1
3
0
10-17-22 date in a format where i want to grep 10, 17, 22, seperately.
Output ...
2
votes
1
answer
2k
views
How to get specific fields of JSON objects for which another field is true
I want to get a specific info from the below command
[root@test opc]# /bin/oci compute instance list-vnics --instance-id ocid1.instance.oc1.ap-mumbai-1....
1
vote
2
answers
267
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
...
0
votes
5
answers
1k
views
How to ignore all text containing special character more than once?
Sample Input:
apple_ig
rabbit_cat_ig
dog_ig
bird_duck_ig
orange_ig
goat_ig
Expected output:
apple_ig
dog_ig
orange_ig
goat_ig
I need to ignore all data that contains underscore _ more than once in ...
1
vote
1
answer
302
views
Unix Script - On specific pattern, need to exit tail -f, and use awk to run separate script
So, I need to make a modification to a start script to clean up the /tmp once the application is fully loaded. After some research, I found a command for my script that does this:
tail -f /home/user1/...
1
vote
1
answer
256
views
exclude a string when a range of numbers is successfully found. Followup to a previous questions about searching strings in a txt of house addresses
Context
This is a follow-up question to a question I asked previously. A new detail/issue arose that I wasn't aware of prior to getting some amazing help from Kamil Maciorowski and Cyrus. I chose ...
0
votes
5
answers
726
views
How to extract fields for specific line numbers that are passed as parameters to a bash script?
I have a file named data.txt with the following content:
1 aFDLKSFD_FDSJFskadfsff_fsadklfj_fdsaf IT524234
2 bFDLKSFD_FDSJFskadfsff_fsadklfj_fdsaf IT524234
3 ...
-1
votes
1
answer
912
views
Replacing numbers in a text file in each iteration with random values
I have a text file with the following content:
number of apples 7
I would like to run the shell script and modify the number with random values for say 5 iterations. So I need my output to look like ...
-3
votes
4
answers
343
views
Bash Script help- Text Parsing & Output
I am having text file of the following type,
a b c d
-- -- -- --
1 ok device issue Some Action which
has to be taken which
...
-2
votes
3
answers
340
views
String manipulation and piping it to bash
I have a file with contents like this:
...
packageEARTH {
...
}
packageMARS {
...
}
packageVENUS {
...
}
...
So I want to do a multi-step process. I ...
1
vote
1
answer
709
views
Add a line before a string in a file using awk
I want to add a line
allow = alaw
before a string
nat = no
in a file sip.conf (or any text based file). If allow = alaw already exists before nat = no it should not be added. And the line should not ...
1
vote
1
answer
49
views
Update data using search & replaces
get_data.txt
ald900 NON-Prod GOOG037-A US
ald9024 NON-Prod GOOG037-A SRI-LANKA
ald978 NON-Prod GOOG037-A JAPAN
I have two given data. I need to search in get_data.txt ...
2
votes
4
answers
542
views
How do I filter certain lines except the ones following a pattern in AWK
I have a log file with a structure that follows:
Timestamp header
Log line
An example of such file as follows:
Jun 03, 2020 10:39:04 AM pacakge.subpackage.Class method
FINE: ---
Jun 03, 2020 10:39:...