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

I would like to print a string with a variable formula using awk in multiple...

I have inherited a script which takes a file and extracts some data from it, creates a new file and based on this data writes a formula based on the data extracted. The data extracted varies in count...

View Article


How to remove the first colon ':' from a timestamp?

I am new to programming!! Can anyone help to remove the : at the first position in a timestamp: :29.06.2019 23:03:17 Presently I am trying to do it using awk/cut commands as shown below: TDS="$(grep...

View Article


AWK function filter log

I want to read a log and make some decisions depending on what is happening with my program. My script is based on ffmpeg and I am redirecting the stdout to make the log. Then I am reading the log to...

View Article

Bash, awk, compare 2 cols divided by , and fields in "

System Linux local 5.0.0-27-lowlatency #28-Ubuntu SMP PREEMPT Tue Aug 20 20:33:37 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux Question How can I compare two cols divided by , and fields in " when , is...

View Article

Bash, get value from json line

System Linux local 5.0.0-27-lowlatency #28-Ubuntu SMP PREEMPT Tue Aug 20 20:33:37 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux Issue I have input file. { "article": {"code": "01333457004","name": "ALAZANIS...

View Article


How to print data column wise in shell script

I'm trying get some data using github API's and print in a csv file. I'm get output something like below 4 3 2 1 user-1 user-2 user-3 user-4 I'm trying to achieve that the data should be displayed...

View Article

Remove words from a column in a file

I have file which contains something like below 5,test,2019-09-27T11:06:23Z,closed,harshavardhanc,2019-09-27T11:09:28Z,2,2 4,test,2019-09-26T16:56:40Z,closed,harshavardhanc,2019-09-26T16:57:02Z,1,1...

View Article

Add specific text/tag after every few lines in bash

I have a text file where I have to add tags (in the form of normal text) to a .txt file. For example, suppose I have a text file like this: a b c d e f g h I want to add the tags <hello> and...

View Article


Compare 2 cols; when 1st col > 2nd col, remove 2nd col

How can I compare 2 cols in csv file, divided by ,, and cols contains quotes " when , is present in generated col, and when 2nd col > 1st col, then remove 2nd (last) col. I did something similar,...

View Article


How to convert gjf format to xyz format?

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

View Article

Extract Strings from an HTML file

I need an sh script will get text from an html file I download the file withwget website.com/link_123456789 -O 'testfile.txt'the full contents of that file are located at this pastebinBut you don't...

View Article

Add or append new column to csv file using shell script

I have a CSV file it includes some columns, in that I have the start time and end time. My requirement is to get the difference between the time and add the difference to a new column.I'm getting the...

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


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/cm 06/01/2000,conductivity,22,uS/cm 26/01/2000,conductivity,26,uS/cm 09/02/2000,conductivity,32,uS/cm 23/02/2000,conductivity,33,uS/cm I...

View Article

How would you separate fields with multiple spaces and store them in an array?

For example : In my file mytxtfield1 field2 ------ ------- this are numbers 12345 this letters abc def ghi Let's say I want to store the first field in an array i=0 while read line; do...

View Article


How to manipulate specific fields?

I have a csv file. Its line numbers are max 25.Headings are time(UTC)(1st field), latitude(2nd field), longitude(3rd field), depth (4th field), mag(5th field), place (14th field) and so forthSample...

View Article

How do I get values from string and then convert these values to different...

Data format as follows:2019 12 18 18 15 05 TIMESTAMP 2019 12 18 23 15 05 TIMESTAMP These values in strings are respectively year, month, day, hour, minute, and second. I try to write awk script. I...

View Article


Replace XML tags by numbers

Suppose i have an xml like this<a> hey how are </a> <a> where are you </a> I want to change them and assign number like this--1.hey how are 2.where are you I would prefer the...

View Article

How to calculate average of 2nd field from files?

I have many files.Files format as followscccedddh.yyiwhereddd: 3-digit the day of the yearyy : 2-digit yearExample: jplg0010.19iThe files consist of two fields. I want to print output as yyyy-mm-dd(or...

View Article

Bash script to split file by its content renaming the split files from an...

So far I was only reading, but now I have to start with a complicated question. I was googling crazy but I can't find an answer and it must be in BASH. (Thank you for the ideas like Perl, not an option...

View Article
Browsing all 102 articles
Browse latest View live


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