Quantcast
Channel: Active questions tagged bash+awk - Ask Ubuntu
Browsing latest articles
Browse All 97 View Live

Image may be NSFW.
Clik here to view.

Is there any online awk command "explainer"?

First, I am not sure where I should ask this question. Please point me out the correct forum if this place is not meant for this.I am looking for a tool that can explain awk commands.As a reference,...

View Article



Combine two files and aggregate another column

I'm trying to compare two files, on basis of the id column,A.txt contains ID, NAME fields.B.csv contains ID, NAME, PLACE, DATE,I want find which month had most of the ID's from a.txtI'm trying to do...

View Article

AWK with RS not matching a pattern (asking again becuase I accidently labled...

I have an odt file with blank lines between lines of text. I want to search for a term and output the whole group of text where there is a match to the term. My approach is to say that the blank lines...

View Article

Using awk for a bash script that defines a "minimum packages set"

I would like to write a script with the following requirements:in input, get a list of packages available via apt. In there you may have some packages that are automatically installed by other packages...

View Article

awk NR variable not working as expected, getting the whole line while asking...

echo cat:cat Records.txtecho ""echo Using a digit for the second record:record_id=$(awk 'NR==2{print $1; exit}' Records.txt)echo $record_idecho ""a=2echo a is set to $aecho ""echo Using a variable and...

View Article


Convert HTML to text format

I want to extract the page content from this HTML file:<BR /><TABLE style=border-color:#32506d border=1 cellspacing=0><caption class=header...

View Article

Editing wc -l src Output

I am new to the Topic and working on a few bash commands.I am stuck at a task where i Need t ouput my result in a specific Format.wc -l folder/*The Output gives me:0 folder/file13 folder/file23 totalI...

View Article

How to use awk to edit a specifc line set by a variable (awk NR, -i inplace...

If file is:this is line onethis is line twothis is line threeI want to do something like:awk -i inplace -v line_number=$line_number 'NR == line_number {print $1}' file Lets say line_number=1. Then...

View Article


awk parameter substitution fails

I am on Ubuntu 20.04 Mate Desktop environment.I encounter a strange failure when I attempt to pass the date string to regex query in the following line : date="2020-12-11" cat /var/log/dpkg.log | awk '...

View Article


Awk/Sed commands find and replace pattern

I have a file with data like the following. xyz can be anything, so I want to replace it.variable "azure_spoke_gateways" { default = { spoke1 = { name = "xyz" size = "max" vpc = "azure_spoke1_vnet" },...

View Article

Pass a variable in awk command

spke="myvaribale" var="cidr" val=$azure_spoke2_vnet_cidr clp="azure_vnets"I am placing these variable in this command : I dont want to write this myvaribale in awk rather I want to use $spke variable...

View Article

awk -v var=$var /var/ is not working as expected

Portion of file:<style:style style:name="P15" style:family="paragraph" style:parent-style-name="Table_20_Contents"><style:paragraph-properties fo:text-align="center"...

View Article

what NF stands for in awk?

I know NF is the last element, as explained here:NF is a predefined variable whose value is the number of fields in the current record. awk automatically updates the value of NF each time it reads a...

View Article


Extract the content from a file between two match patterns (Extract only HTML...

I have file which contains different kind of text formats, my goal is to extract only HTML part and create a file with this HTML code. I think it is possible with grep or awk. My file contains also...

View Article

Extracting name between two delimiters via awk

I have a string like this<user>@<server>:<port>:/foo/barand I would like to extract the user, server, port and directory.The user can easily be extracted byecho <string> | awk...

View Article


how to split a string from a column using awk

I am a noob in Linux. I have a file like this: col1 col2 col3 ID1234567-DNA_A01 chr1_10203040_T/C gene 0 ID1234568-DNA_A02 chr1_10203050_T/A gene 0 ID1234569-DNA_A03 chr1_10203060_A/G gene 0...

View Article

why is my output not correct while dividing by a variable in awk?

I wrote a small watch script to monitor the load average on a Linux server (just for learning purposes but watch uptime wasn't giving the output I want).It works well, but to get the load average for...

View Article


How to convert gjf format to xyz format?

The gjf format is as follows:%chk=test.chk# hf/3-21g geom=connectivityTitle Card Required0 1 C 0.53424883 1.46721985 -0.02620215 H 0.89090326 0.45840985 -0.02620215 H 0.89092167 1.97161804 0.84744935 H...

View Article

How to check whether one number range from one file is the subset of other...

I'm trying to find out whether range1 numbers [both columns a and b] are the subset or lying between range2's columns [both columns b and c].range1 a b15 20 8 1037 4432 37range2 a b c chr1 6 12 chr2 13...

View Article

Using sed or awk to remove near-duplicates

I currently use the following to get as close as I can do to a filecut -d '' -f 3- /var/log/issues.log | sed -E 's/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}//g' | sort -uSo far it gets rid of the...

View Article

Replace a text within single quotes with another string using sed(just a...

I have a file with the following content:$ cat file.txtCREATE COLLATION public.collation123 (provider = libc, locale = 'fr-FR'); CREATE COLLATION public.collation_1 (provider = libc, locale = 'bas');...

View Article


How to get the average ping time?

Here's a real result of my ping 192.168.1.1 command:64 bytes from 192.168.1.1: icmp_seq=964 ttl=64 time=1018 ms64 bytes from 192.168.1.1: icmp_seq=965 ttl=64 time=921 ms64 bytes from 192.168.1.1:...

View Article


Delete all lines from a line with certain string until another line with a...

file.txt:start some text works "HELLO" foo test sum otherendstart som "other" line with text 'also' thing fooendand I want to delete the line in which "HELLO" is located and then delete all following...

View Article

How can I capitalise a word proceeding a specific word

Lets say I want to capitalise the first word following the word jumped. Example belowOriginal text:the cow jumped over the moonAmended textthe cow jumped OVER the moonI have tried awk and sed but cant...

View Article

--- Article Not Found! ---

*** *** *** RSSing Note: Article is missing! We don't know where we put it!!. *** ***

View Article


--- Article Not Found! ---

*** *** *** RSSing Note: Article is missing! We don't know where we put it!!. *** ***

View Article

Couldn't able to store a output of awk command

I have been trying to print git clone progress on more minimalistic way for my project.AimInstead of printing a whole git clone output on screenremote: Enumerating objects: 1845678, done. remote:...

View Article

What does this command mean: `echo $line | awk -F "\t"'{print $1;}'`?

I'm new to this, and I was wondering specifically what awk -F "\t" means.

View Article

AWK issue on Bash script

I need to shortlist the logs between the particular timestamps.I can achieve it by using the below command.awk '$a>="Feb 5 10:44:*" && $a<="Feb 5 10:54*"' /var/log/xxxxBut it's not...

View Article



What is a practical way to list every character used in a file (Bash) (Regex)

How can I turn this:Johnny's penguin, (Tuxie), likes the following foods: French fries, and beef.To this: abcdefghiklnoprstuwFJT',():.(These are the total characters used in the input)Please note that...

View Article
Browsing latest articles
Browse All 97 View Live




Latest Images