Quantcast
Channel: Active questions tagged bash+awk - Ask Ubuntu
Browsing all 102 articles
Browse latest View live
↧

Compare the two column strings and 2nd column string count should match with...

File110/22/2020 LDYA LDYA-PLSP10/22/2020 LDYA LDYC-PLSP10/18/2020 LBQD LBQD-PLSP10/18/2020 LDMN LDMN-PLSP10/18/2020 LDMN LLMA-PLSP10/18/2020 LDMN LDMN-DLV510/18/2020 LKNC LKNC-PLSPFile2KLS3 LDYA...

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


if specifc line contains substring then output another substring

I want to look for a string on every line of a file and if it exists, return a different specific string.I have this code:Numlines=$(grep "" -c File.txt)for (( line=1; line<=$Numlines; line++ )) ;...

View Article

How to rearrange text file via awk?

I wanna print field (from 4th to the last field) as new line for each by inserting increasing arithmetically variable (from 5 to 25) after 3rd field in the text file.Data format:01.01.1995 01:00 1.0...

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 add new columns to CSVs with the same text in all lines

This a sample of my input file:22/12/1999,conductivity,42,uS/cm06/01/2000,conductivity,22,uS/cm26/01/2000,conductivity,26,uS/cm09/02/2000,conductivity,32,uS/cm23/02/2000,conductivity,33,uS/cmI would...

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

bash to find each time occurrence in text file, then replace with increased...

i need to find each time occurrence in text file,then replace each occurrencewith increased (or decreased) time.Example 01i have the following "file_01.txt"i need to "add" for example 00:01:02,999(zero...

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


I want to search with RETCODE & find 5 lines above beginning with NE : . Is...

**NE : TALS1_TO**Report : +++ TALS1_TO 2021-01-25 02:02:18O&M #806356831%%/*1884960535 MML Session=1611550934*/MOD...

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
Browsing all 102 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>