Skip to main content

All Questions

-2 votes
4 answers
205 views

Getting output of /usr/bin/time in CSV format

I am using gawk to parse the output of macos' /usr/bin/time into CSV format as shown below. The problem is that gawk is returning the 'involuntary context switches' value for 'voluntary context ...
jonathannah's user avatar
0 votes
1 answer
150 views

AWK: regex is not processed when passed as a variable

Any suggestions? I read: Escape Sequences (The GNU Awk User’s Guide) Representative Example $ Filesystem='/dev/mapper/vgubuntu-Media' $ FilesystemRegex="$(echo "${Filesystem}" | sed &...
Porcupine's user avatar
  • 2,146
2 votes
4 answers
396 views

linux + delete by bash script the unused/incorrect UUID number/s from fstab file

our goal is to create bash script that delete the unused / unnecessary UUID number/s from /etc/fstab file , brief background - in our labs , we have more then 500 RHEL servers , and we want to fix the ...
yael's user avatar
  • 13.9k
-1 votes
3 answers
584 views

How to match end of last string in file which does not end with punctuation

I'm trying to search a directory for files which do not end in a period. I'm trying to list the file name with the final ascii character which is not followed by period/ punctuation. I've looked all ...
Doodling's user avatar
2 votes
3 answers
155 views

Replacing math equations by result

What is the best way to replace, in a file, equations found using some predefined regex with the result. Let's say each equation formula is compatible with bc -l (basic calculator with float numbers ...
taalf's user avatar
  • 23
6 votes
8 answers
4k views

Use awk to delete everything after the ","

I have a variable, var, that contains: XXXX YY ZZZZZ\n aaa,bbb,ccc All I want is aaa in the second line. I tried: out=$(echo "$var" | awk 'NR==2{sub(",.*","")}' ) but I ...
Dark_Stoner's user avatar
0 votes
1 answer
904 views

How to use BASH variable for AWK filtering results

I have this script, I'm getting first letter of my directory name, and I wan't to get directory names that start with the same letter and write to textfile. The for loop is looping list of directory ...
Brokolicový Džuß's user avatar
1 vote
3 answers
199 views

How to use a file of search patterns to search for exact words in the final column of a csv?

This issue is covered as separate topics, but I can't get everything to work together. I have a tsv file, here is an example line: (file1) NODE_1_length_45927_cov_22.029055_g0_i0 WP_055195622.1 93.1 ...
Nick Bailey's user avatar
0 votes
2 answers
451 views

Append text to flagged output of awk

I have a function that takes a filename. It then runs a command and filters the output (exclusive) between two patterns, then it outputs comma separated values with the filename output of the command. ...
dylanjm's user avatar
  • 211
-1 votes
1 answer
164 views

Match system path with awk in if statement

I am trying to catch if the file system was mounted on a directory tree with: mount | awk '{ if ( $3 == /mnt/pxe ) print mounted }' But the string is not catched even though mount exists. The mount ...
l00p's user avatar
  • 263
2 votes
3 answers
2k views

Using regular expression to get latest pip package version

I'm trying to parse the output of this pip install to get the latest package version. pip install package== ERROR: Could not find a version that satisfies the requirement package== (from ...
bottega's user avatar
  • 23
0 votes
2 answers
2k views

And operation and case insensitivity in awk regular expression?

I'm trying to match filenames that contain two text patterns but the matching process should ignore case. Neither of the following regular expressions work: Setting the awk variable 'IGNORECASE' to a ...
bit's user avatar
  • 1,166
0 votes
2 answers
165 views

bash + regular expression + capture java version [closed]

how to capture the jdk1.8.0_112 under /usr/jdk64 /usr/jdk64/jdk1.8.0_112/ while jdk1.8.0_112 is example and could be any other version as jdk1.7.0_112 jdk3.8.2_112 jdk1.8.0_117 jdk1.2.0_112 jdk2.7....
yael's user avatar
  • 13.9k
0 votes
2 answers
145 views

Changing two strings on same line matched by a regex

I have a number of variables in a .dat file that I automatically changed with a script. One of these files has a parameter, bar, that is arranged as such in a .dat file: var1 var2 var3 foo bar T ...
eoncarlyle's user avatar
-2 votes
1 answer
61 views

replace name after specific syntax

We have Bash script. We want to change the name - master02 with $machine_master in the Bash script. value=master02_up #master02 http://master02.$domain:8080 How to change master02 to $...
yael's user avatar
  • 13.9k

15 30 50 per page