Skip to main content

All Questions

Tagged with
1 vote
2 answers
58 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/&...
6 votes
7 answers
2k views

Grep that works with overlapping patterns

I want to count the number of repeating patterns aa in a very big file. So I use the following command: grep -o "aa" ./bwt/dblp.txt | wc -l This works, except when I have a string such as aaa, which ...
-1 votes
1 answer
54 views

awk inside function causing errors

I'm trying to add the following to my .bashrc: cpu_info() { top -b -n1 | grep Cpu(s) | awk '{print $2 + $4}' } but bash is telling me: bash: .bashrc: line 131: syntax error near unexpected token `...
0 votes
2 answers
5k views

Find specific folder path in s3 bucket

I'm searching a folder in s3 bucket using this command aws s3 ls s3://bucketname/dir1/dir2/dir3 --recursive | grep -i 'dir3' It's getting results like dir1/dir2/dir3/1/aaa.txt dir1/dir2/dir3/1/bbb....
43 votes
16 answers
123k views

How can I remove all comments from a file?

I have a file which includes comments: foo bar stuff #Do not show this... morestuff evenmorestuff#Or this I want to print the file without including any of the comments: foo bar stuff morestuff ...
0 votes
3 answers
2k views

Find a value in a specific position when the only information you have is the position

I have a csv file approximately 16,000 rows long, with two fields. The first field contains a list of numeric values, and the second field contains a list of first and names delimited by semi-colons ...
-2 votes
4 answers
80 views

How to keep previous and current line if the previous line contains common text?

How to keep previous and current line if the previous line contains common text? I have a main file like this: Hello_world Anna Frank Jeremy Hello_earth Jessie James I would want 3 output files like ...
1 vote
3 answers
3k views

AWK printing columns based on column number and pattern match condition

I need to reformat the output of the following command using awk for static and dynamic column numbers: ps -eopid,lstart,cmd | grep java |grep -v grep following would be sample input to the awk ...
0 votes
1 answer
5k views

shell script to monitor current errors in logfile

This script monitors logfile for pattern "ora",pull error details and send email.In this case i want to pull only the last error which come in logfile. I set crontab for every 5 minutes,so grep pull ...
0 votes
0 answers
71 views

Text processing grep and awk together on live script not working

I am using ssh to login to a remote server (Ubuntu), and then issue a command which outputs text/value each sec (live script). In the live output, I want to filter out the lines containing '...
-3 votes
4 answers
109 views

How to catch all lines of a repeating pattern and do some actions with the subresults

I am looking for a possibility to catch in a repeating text pattern all variable amount of lines between them and then do an action with it in bash. Example text: Total: text1 text2 Total: text3 Total:...
2 votes
2 answers
63 views

Listing a certain part of filenames and their contents

I have a Linux machine with BusyBox, which has a directory called /data/var/lib/connman.  That directory holds some directories that I'm not interested in.  But it contains many .config files that ...
7 votes
4 answers
1k views

How to use sed, grep, or awk to keep certain lines in a file depending on line numbers in another file

I have two files. File1 contains some sentences, and File2 contains the line numbers I want to keep in File1. For example, File1: He is a boy. She is a cook. Okay. She went to school. She is pretty. ...
0 votes
1 answer
2k views

Passing Argument to Grep to get specific output

I am a newbie to Unix. Learning on my own.....I am writing a simple shell script to pull the Name of a dealer who was working a shift at the specified time where search takes place from multiple files ...
0 votes
5 answers
160 views

How to add content to a file before the last } character using Busybox utilities?

There is a file with contents { "first_name": "John", "last_name": "Smith", "is_alive": true, "age": 27, "address": { ...

15 30 50 per page
1
2 3 4 5
73