Awk line 1 syntax error at or near

I'm getting this above syntax error and i can't decipher what is wrong with it. I'm trying to do a float value in BASH. Hence i used this command called the awk to achieve the target. while $emp...

The reason you get a syntax error in your Awk script is because when $getPrice is empty, then the script is actually just

BEGIN{if (>0) exit 1}

The proper way to import a shell variable into an Awk script as an Awk variable is by using -v:

awk -vprice="$getPrice" 'BEGIN { if (price > 0) exit 1 }'

I also had a look at the flow of contol in your script, and rather than using the $empty variable, you could just exit the loop when a correct price has been entered:

while true; do
    read -p 'Price : ' getPrice

    # compare float value using awk
    if awk -vprice="$getPrice" 'BEGIN { if (price <= 0) exit(1) }'
    then
      PRICE[$COUNT]="$getPrice"
      break
    fi

    echo 'Please put in the correct (positive) price figure!' >&2
done

Additional detail after comments:

The user should be alerted about invalid input if the value entered is not a number or if it’s negative. We can test the inputted value for characters that are not supposed to be there (anything other than the digits 0 through to 9 and the decimal point):

while true; do
    read -p 'Price : ' getPrice

    if [[ ! "$getPrice" =~ [^0-9.] ]] && 
        awk -vprice="$getPrice" 'BEGIN { if (price <= 0) exit(1) }'
    then
        PRICE[$COUNT]="$getPrice"
        break
    fi

    echo 'Please put in the correct (positive) price figure!' >&2
done

Содержание

  1. line 1: syntax error at or near if
  2. 1 Answer 1
  3. Syntax error removing duplicate lines via awk ‘!x[$0]++’ file
  4. 1 Answer 1
  5. Syntax error removing duplicate lines via awk ‘!x[$0]++’ file
  6. 1 Answer 1
  7. Yet another syntax error near unexpected token `(‘ [closed]
  8. 1 Answer 1
  9. The source of the error is elsewhere
  10. Backticks
  11. Aliases
  12. localisation
  13. Журнал лабораторных работ
  14. Журнал
  15. Среда (04/13/11)
  16. Статистика
  17. Справка
  18. О программе

line 1: syntax error at or near if

My code in treat.awk is:

And my input in command prompt is:

There appear an error message such:

How to fix it? I using awk for this code and only traditional version of awk is allowed.
File is only contains «test«.

1 Answer 1

That’s not awk code, that’s csh code. Change the she-bang to

(where that -f is not to take a file as argument like in awk , but to not read the user’s

The awk code to do the same thing would be something like:

If by traditional version of awk, you mean the pre-1985 non-POSIX versions like the /bin/awk of Solaris, then that can’t be done, as those don’t have ARGV and can’t refer to their arguments (other than with FILENAME when processing their arguments as input files). On Solaris, you’d want to use /usr/xpg4/bin/awk to get something close to a standard awk . The wording of your error message suggests you’re using mawk though which is not usually what one would call a traditional version of awk and does support that syntax.

Now, note that that system() would actually call sh to interpret that cat file shell command line¹, so you might as well do the whole thing in sh (which would be a lot better than csh which should really not be used in this century):

¹, also, some arguments starting with — would be taken as option by awk ! With GNU awk , you can use a #! /usr/bin/gawk -E she-bang instead to work around that.

Источник

Syntax error removing duplicate lines via awk ‘!x[$0]++’ file

The file contains

Trying to remove duplicate lines on SunOS via

(as found in another postings) results in a syntax error

What I am missing?

1 Answer 1

awk was first released in the late 70s in Unix V7.

Since then, it has undergone significant changes, some of them not backward compatible.

Like for many other utilities, Solaris (contrary to most other Unices) has taken the stance of sticking with the older obsolete implementation for its default awk utility, and make the newer versions available either under a different name ( nawk ) or at a different location ( /usr/xpg4/bin/awk , that one not available by default in some stripped-down configurations of Solaris 11).

On Solaris, if you use the default environment, you generally get utilities that behave in an ancient/obsolete way. For instance, before Solaris 11, sh in the default environment would not be a standard shell, but a Bourne shell. A lot of other utilities ( grep , sed , tail , df . ) are not POSIX compliant, not even to the 1992 version of the standard.

Solaris is a POSIX (even Unix) certified system (at least in some configurations), however POSIX/Unix only requires a system be compliant in a given (documented) environment (which may not be the default).

So, when you write code that needs to be portable to Solaris, you need either to write in a syntax from another age, or make sure you put yourself in a POSIX environment.

How to do so for a given version of those standards is documented in the standards(5) man page on Solaris.

So, for awk here, you can use:

Which would work in the 1978 awk from Unix v7 and Solaris /bin/awk (in the original awk , you could not use any arbitrary expression as a pattern, it had to be conditions using relational operators like == here).

Or more generally, to have saner (and more portable) versions of all the utilities (including awk ):

Both /usr/bin/getconf PATH and /usr/xpg4/bin/getconf PATH will give you a $PATH like: /usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin , which will get you XPG4 (a superset of POSIX.1-1990, POSIX.2-1992, and POSIX.2a-1992) conformance. On Solaris 11, you also have a /usr/xpg6/bin/getconf which will get you a PATH like /usr/xpg6/bin:/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin for XPG6 (SUSv3, superset of POSIX 2001) conformance (where it conflicts with XPG4, in practice unlikely to affect you).

Источник

Syntax error removing duplicate lines via awk ‘!x[$0]++’ file

The file contains

Trying to remove duplicate lines on SunOS via

(as found in another postings) results in a syntax error

What I am missing?

1 Answer 1

awk was first released in the late 70s in Unix V7.

Since then, it has undergone significant changes, some of them not backward compatible.

Like for many other utilities, Solaris (contrary to most other Unices) has taken the stance of sticking with the older obsolete implementation for its default awk utility, and make the newer versions available either under a different name ( nawk ) or at a different location ( /usr/xpg4/bin/awk , that one not available by default in some stripped-down configurations of Solaris 11).

On Solaris, if you use the default environment, you generally get utilities that behave in an ancient/obsolete way. For instance, before Solaris 11, sh in the default environment would not be a standard shell, but a Bourne shell. A lot of other utilities ( grep , sed , tail , df . ) are not POSIX compliant, not even to the 1992 version of the standard.

Solaris is a POSIX (even Unix) certified system (at least in some configurations), however POSIX/Unix only requires a system be compliant in a given (documented) environment (which may not be the default).

So, when you write code that needs to be portable to Solaris, you need either to write in a syntax from another age, or make sure you put yourself in a POSIX environment.

How to do so for a given version of those standards is documented in the standards(5) man page on Solaris.

So, for awk here, you can use:

Which would work in the 1978 awk from Unix v7 and Solaris /bin/awk (in the original awk , you could not use any arbitrary expression as a pattern, it had to be conditions using relational operators like == here).

Or more generally, to have saner (and more portable) versions of all the utilities (including awk ):

Both /usr/bin/getconf PATH and /usr/xpg4/bin/getconf PATH will give you a $PATH like: /usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin , which will get you XPG4 (a superset of POSIX.1-1990, POSIX.2-1992, and POSIX.2a-1992) conformance. On Solaris 11, you also have a /usr/xpg6/bin/getconf which will get you a PATH like /usr/xpg6/bin:/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin for XPG6 (SUSv3, superset of POSIX 2001) conformance (where it conflicts with XPG4, in practice unlikely to affect you).

Источник

Yet another syntax error near unexpected token `(‘ [closed]

Questions describing a problem that can’t be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers.

Closed 6 years ago .

This one different from the others as:

  1. I’m invoking bash (not sh) in the shebang: #! /bin/bash
  2. I’m running it with ./
  3. File permissions are correct: 755

The line in question is:

The content of $domPATH/duration.seconds is 37603

I can run this at the command line:

and get the result of Duration: 10h 26m when I echo $formattedTIME

But running it in in the script results in:

Extra info: This is on a Raspberry Pi 2 running Jessie.

UPDATE: The error was online 8:

1 Answer 1

A few common trends on why a command doesn’t parse properly in a script but is fine when run on its own:

The source of the error is elsewhere

The shell will report an error on the first thing it doesn’t expect. Here, it doesn’t expect a ( , yet it appears it’s within a quoted string. A possible explanation is that you’re not in a quoted string because the first ‘ there actually closes an earlier unclosed quote instead of opening a new ‘. ‘ on like in:

And that unquoted ( above is unexpected by the shell.

You get similar problems with any structure that is not properly closed or in the wrong format, like a fi without a then .

Backticks

Backticks should really not be used. $(. ) should be used instead.

Inside backticks, is handled differently.

is not OK. Even though echo It\’s OK by itself is OK, as inside backticks, the first two backslashes become one, so it ends up being echo It\’OK .

The $(. ) modern form doesn’t have those problems.

Aliases

aliases are a bit like macros, their expansion undergoes code interpretation again.

would have the problem hidden in the definition of the foo alias.

There are more subtle ones like:

Which without causing syntax errors, cause the parsing to be done in an unexpected way.

Often, functions are more appropriate than aliases

localisation

Some byte sequences can be interpreted differently depending on the locale.

For instance, the 0xa0 byte is the non-breaking space in the ISO-8859-1 character set. And that character happens to be a blank on Solaris, and bash happens to treat all blanks as delimiters (currently only for single-byte characters).

That 0xa0 byte also happens to be part of several UTF-8 characters like à . So you may find that for instance that a script that has:

(with that à written in UTF-8) stops working when run on Solaris in a ISO-8859-1 locale, because that becomes var=X do (where X is the first byte of that à character).

Источник

Журнал лабораторных работ

Журнал

Среда (04/13/11)

Статистика

Время первой команды журнала 11:25:44 2011- 4-13
Время последней команды журнала 12:05:21 2011- 4-13
Количество командных строк в журнале 101
Процент команд с ненулевым кодом завершения, % 19.80
Процент синтаксически неверно набранных команд, % 0.99
Суммарное время работы с терминалом * , час 0.66
Количество командных строк в единицу времени, команда/мин 2.55
Частота использования команд
find 51 |=======================| 23.94%
cat 29 |=============| 13.62%
tr 24 |===========| 11.27%
awk 15 |=======| 7.04%
wc 13 |======| 6.10%
ps 7 |===| 3.29%
.tgz 6 |==| 2.82%
>’ 6 |==| 2.82%
.rpm)’ 5 |==| 2.35%
999) 5 |==| 2.35%
n< 3 |=| 1.41%
cd 3 |=| 1.41%
echo 3 |=| 1.41%
>` 3 |=| 1.41%
n++) 3 |=| 1.41%
pwd 3 |=| 1.41%
xargs 3 |=| 1.41%
=NF 3 |=| 1.41%
> 2 || 0.94%
.tgz 2 || 0.94%
)’ 2 || 0.94%
)` 2 || 0.94%
ls 2 || 0.94%
tgz 2 || 0.94%
rpm 2 || 0.94%
Частота использования этих команд mkdir 1 , *.rpm)» 1 , .ext2) 1 , man 1 , ext2) 1 , *.rpm» 1 , ext2)» 1 , .rpm) 1 , *.rpm)» 1 , .rpm)` 1 , .rpm 1 , for 1 , ‘(if 1 , `(if 1

____
*) Интервалы неактивности длительностью 30 минут и более не учитываются

Справка

В журнал автоматически попадают все команды, данные в любом терминале системы.

Для того чтобы убедиться, что журнал на текущем терминале ведётся, и команды записываются, дайте команду w. В поле WHAT, соответствующем текущему терминалу, должна быть указана программа script.

Команды, при наборе которых были допущены синтаксические ошибки, выводятся перечёркнутым текстом:

Если код завершения команды равен нулю, команда была выполнена без ошибок. Команды, код завершения которых отличен от нуля, выделяются цветом.

Обратите внимание на то, что код завершения команды может быть отличен от нуля не только в тех случаях, когда команда была выполнена с ошибкой. Многие команды используют код завершения, например, для того чтобы показать результаты проверки

Команды, ход выполнения которых был прерван пользователем, выделяются цветом.

Команды, выполненные с привилегиями суперпользователя, выделяются слева красной чертой.

Изменения, внесённые в текстовый файл с помощью редактора, запоминаются и показываются в журнале в формате ed. Строки, начинающиеся символом » » — добавлены.

Для того чтобы изменить файл в соответствии с показанными в диффшоте изменениями, можно воспользоваться командой patch. Нужно скопировать изменения, запустить программу patch, указав в качестве её аргумента файл, к которому применяются изменения, и всавить скопированный текст: В данном случае изменения применяются к файлу

Для того чтобы получить краткую справочную информацию о команде, нужно подвести к ней мышь. Во всплывающей подсказке появится краткое описание команды.

Если справочная информация о команде есть, команда выделяется голубым фоном, например: vi . Если справочная информация отсутствует, команда выделяется розовым фоном, например: notepad.exe . Справочная информация может отсутствовать в том случае, если (1) команда введена неверно; (2) если распознавание команды LiLaLo выполнено неверно; (3) если информация о команде неизвестна LiLaLo. Последнее возможно для редких команд.

Большие, в особенности многострочные, всплывающие подсказки лучше всего показываются браузерами KDE Konqueror, Apple Safari и Microsoft Internet Explorer. В браузерах Mozilla и Firefox они отображаются не полностью, а вместо перевода строки выводится специальный символ.

Время ввода команды, показанное в журнале, соответствует времени начала ввода командной строки, которое равно тому моменту, когда на терминале появилось приглашение интерпретатора

Имя терминала, на котором была введена команда, показано в специальном блоке. Этот блок показывается только в том случае, если терминал текущей команды отличается от терминала предыдущей.

Вывод не интересующих вас в настоящий момент элементов журнала, таких как время, имя терминала и других, можно отключить. Для этого нужно воспользоваться формой управления журналом вверху страницы.

Небольшие комментарии к командам можно вставлять прямо из командной строки. Комментарий вводится прямо в командную строку, после символов #^ или #v. Символы ^ и v показывают направление выбора команды, к которой относится комментарий: ^ — к предыдущей, v — к следующей. Например, если в командной строке было введено: в журнале это будет выглядеть так:

Если комментарий содержит несколько строк, его можно вставить в журнал следующим образом: В журнале это будет выглядеть так:

Интересно, кто я?
Программа whoami выводит имя пользователя, под которым
мы зарегистрировались в системе.

Она не может ответить на вопрос о нашем назначении
в этом мире.

Для разделения нескольких абзацев между собой используйте символ «-«, один в строке.

Комментарии, не относящиеся непосредственно ни к какой из команд, добавляются точно таким же способом, только вместо симолов #^ или #v нужно использовать символы #=

Содержимое файла может быть показано в журнале. Для этого его нужно вывести с помощью программы cat. Если вывод команды отметить симоволами #!, содержимое файла будет показано в журнале в специально отведённой для этого секции.

Для того чтобы вставить скриншот интересующего вас окна в журнал, нужно воспользоваться командой l3shot. После того как команда вызвана, нужно с помощью мыши выбрать окно, которое должно быть в журнале.

Команды в журнале расположены в хронологическом порядке. Если две команды давались одна за другой, но на разных терминалах, в журнале они будут рядом, даже если они не имеют друг к другу никакого отношения. Группы команд, выполненных на разных терминалах, разделяются специальной линией. Под этой линией в правом углу показано имя терминала, на котором выполнялись команды. Для того чтобы посмотреть команды только одного сенса, нужно щёкнуть по этому названию.

О программе

LiLaLo (L3) расшифровывается как Live Lab Log.
Программа разработана для повышения эффективности обучения Unix/Linux-системам.
(c) Игорь Чубин, 2004-2008

Источник

Awk works with record delimiters (i.e. space, coma, semicolon…). Your input file is not with delimiters, is presented as columns formatting. And unfortunately, some data columns (3 and 4) contain spaces.

You could use this

cut -c 1-13,84- cmd.txt > cmd2.txt

or this:

awk  '{print substr($0,1,12) " " substr($0,84)}' cmd.txt > cmd2.txt

The big problem with those solutions, that the length of each column!

But, it’s possible to determine the lengths:

Awk script file columns.awk:

#! /usr/bin/awk -f

BEGIN {
    COLS[++NB_COLS] = "Port"
    COLS[++NB_COLS] = "Protocol"
    COLS[++NB_COLS] = "Type"
    COLS[++NB_COLS] = "Board Name"
    COLS[++NB_COLS] = "FQBN"
    COLS[++NB_COLS] = "Core"
}
NR == 1 {
    for (COL in COLS) {
        START_COL[COL] = index($0, COLS[COL])
        if (COL > 1) {
            LEN_COL[COL - 1] = START_COL[COL] - START_COL[COL - 1] - 1
        }
    }
    LEN_COL[NB_COLS]=length($0)
}
{
    print substr($0, START_COL[1], LEN_COL[1]) " " substr($0, START_COL[6], LEN_COL[6])
}

With:

chmod 755 columns.awk

Used like:

./columns.awk cmd.txt > cmd2.txt

cmd2.txt file content:

Port         Core
/dev/ttyACM0 
/dev/ttyACM1 arduino:avr
/dev/ttyAMA0 
/dev/ttyAMA1 
/dev/ttyAMA2 
/dev/ttyAMA3 
/dev/ttyS0   
/dev/ttyUSB0 
/dev/ttyUSB1 
/dev/ttyUSB2 
/dev/ttyUSB3 

lebossejames

Posts: 37
Joined: Thu Jun 20, 2019 2:10 pm

awk regular expression

Hello,

I try my bash script on my raspbian buster, i get this error of this command (goal get path of my external devices):

Code: Select all

lsblk | grep sd | awk '{if ( $7~/[/][_a-zA-Z0-9-]*[/][_a-zA-Z0-9-]*[/]*$ ) print $7;}'
awk: line 1: regular expression compile failed (bad class -- [], [^] or [)
[
awk: line 1: syntax error at or near ]
awk: line 1: regular expression compile failed (bad class -- [], [^] or [)
][_a-zA-Z0-9-]*[


Works fine on my computer with Ubuntu.

Have you an idea of my problem?

Thank you.


trejan

Posts: 5368
Joined: Tue Jul 02, 2019 2:28 pm

Re: awk regular expression

Fri Sep 17, 2021 7:15 pm

lebossejames wrote: ↑

Fri Sep 17, 2021 6:38 pm


Works fine on my computer with Ubuntu.

You’re missing a / after the $

lebossejames wrote: ↑

Fri Sep 17, 2021 6:38 pm

Have you an idea of my problem?

Debian uses mawk. Ubuntu uses gawk. They’re not the same. Use / instead of [/] as mawk considers / to be the start of an ERE constant.


jbudd

Posts: 2091
Joined: Mon Dec 16, 2013 10:23 am

Re: awk regular expression

Sat Sep 18, 2021 2:49 am

Or install and use gawk. There will still be a / missing from the end of your pattern though, as Trejan says.



User avatar

jahboater

Posts: 8511
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: awk regular expression

Sat Sep 18, 2021 7:55 am

lebossejames wrote: ↑

Sat Sep 18, 2021 7:47 am


You say :

Code: Select all

lsblk | grep sd | awk '{if ( $7 ~ /[_a-zA-Z0-9-]*/[_a-zA-Z0-9-]*/*$/ ) print $7;}'
awk: 1: unexpected character ''


?

As trejan said above, use / not /
You are escaping the delimiter.


ame

Posts: 6431
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: awk regular expression

Sat Sep 18, 2021 10:43 am

Some people, when confronted with a problem, think «I know, I’ll use regular expressions.» Now they have two problems.

Jamie Zawinski

Hmm. What can I put here?


User avatar

jahboater

Posts: 8511
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: awk regular expression

Sat Sep 18, 2021 11:24 am

It could be simplified or made more readable.

For example, inside the [] character classes, use [:alnum:] instead of a-zA-Z0-9
Does awk allow delimiters other than / ??


lebossejames

Posts: 37
Joined: Thu Jun 20, 2019 2:10 pm

Re: awk regular expression

Sat Sep 18, 2021 12:44 pm

jahboater wrote: ↑

Sat Sep 18, 2021 7:55 am

lebossejames wrote: ↑

Sat Sep 18, 2021 7:47 am


You say :

Code: Select all

lsblk | grep sd | awk '{if ( $7 ~ /[_a-zA-Z0-9-]*/[_a-zA-Z0-9-]*/*$/ ) print $7;}'
awk: 1: unexpected character ''


?

As trejan said above, use / not /
You are escaping the delimiter.

I get now:

Code: Select all

lsblk | grep sd | awk 'if ( $7 ~ /[_a-zA-Z0-9-]*/[_a-zA-Z0-9-]*/*$/ ) {print $7;}'
awk: ligne de commande:1: if ( $7 ~ /[_a-zA-Z0-9-]*/[_a-zA-Z0-9-]*/*$/ ) {print $7;}
awk: ligne de commande:1: ^ syntax error
awk: ligne de commande:1: if ( $7 ~ /[_a-zA-Z0-9-]*/[_a-zA-Z0-9-]*/*$/ ) {print $7;}
awk: ligne de commande:1:           ^ la barre oblique inverse n'est pas le dernier caractère de la ligne
awk: ligne de commande:1: if ( $7 ~ /[_a-zA-Z0-9-]*/[_a-zA-Z0-9-]*/*$/ ) {print $7;}
awk: ligne de commande:1:           ^ syntax error


GlowInTheDark

Posts: 2331
Joined: Sat Nov 09, 2019 12:14 pm

Re: awk regular expression

Sat Sep 18, 2021 1:09 pm

It could be simplified or made more readable.

No doubt, but I didn’t want to hijack this thread into another «human compiler» thing.

For example, inside the [] character classes, use [:alnum:] instead of a-zA-Z0-9

FWIW, as a matter of style, I never quite cottoned to those «character class» thingies; I avoid using them. It seems weird things happen when you do — you start to begin to worry about «Well, with whatever LANG (and so on) settings I have, is 7 still considered to be a digit?» type questions.

Does awk allow delimiters other than / ??

No. And it can be annoying at times, but you learn to live with it. Yes, I know that «sed» and «vi» (i.e., «ex») do allow it.

Poster of inconvenient truths.

Back from a short, unplanned vacation. Did you miss me?


User avatar

jahboater

Posts: 8511
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: awk regular expression

Sat Sep 18, 2021 1:23 pm

GlowInTheDark wrote: ↑

Sat Sep 18, 2021 1:09 pm


FWIW, as a matter of style, I never quite cottoned to those «character class» thingies; I avoid using them. It seems weird things happen when you do — you start to begin to worry about «Well, with whatever LANG (and so on) settings I have, is 7 still considered to be a digit?» type questions.

Isn’t that one of the benefits? For example [A-Z] works fine in any sensible character set, but I don’t think it will work with EBCDIC which has gaps (common on mainframes). Whereas a or [:alpha:] probably would work.

Its true CCL’s can get very complicated unless you are comfortable with set theory.
Some applications allow subtraction …..
[[:alnum:]-[:digit:]] is the same as [:alpha:]


jbudd

Posts: 2091
Joined: Mon Dec 16, 2013 10:23 am

Re: awk regular expression

Sat Sep 18, 2021 1:36 pm

Edited!

Awk is a pattern / action language.
A pattern is contained between / and /
An action is contained between { and }
When data matches the pattern, the action is performed.
And on the command line you have to enclose the whole awk program between single quotes.

You are using if( ) which (I think) has to be within the action. But you don’t need if( ). Awk is designed specifically to do stuff if a field or fields match the pattern.

All of these should work:
lsblk | grep sd | awk ‘{ if( $7 ~ /[_a-zA-Z0-9-]*/[_a-zA-Z0-9-]*/*$/) print $7}’
lsblk | grep sd | awk ‘$7 ~ /[_a-zA-Z0-9-]*/[_a-zA-Z0-9-]*/*$/ {print $7}’
lsblk | grep sd | awk ‘/[_a-zA-Z0-9-]*/[_a-zA-Z0-9-]*/*$/ {print $7}’
lsblk | awk ‘/sd[a-z][0-9]/ {print $7}’

And maybe even these, though you get a blank line.
lsblk | grep sd | awk ‘{print $7}’
lsblk | awk ‘/sd/ {print $7}’

Attachments
Untitled 5.jpg
Untitled 5.jpg (105.63 KiB) Viewed 853 times

Last edited by jbudd on Sat Sep 18, 2021 2:12 pm, edited 7 times in total.


GlowInTheDark

Posts: 2331
Joined: Sat Nov 09, 2019 12:14 pm

Re: awk regular expression

Sat Sep 18, 2021 1:52 pm

Isn’t that one of the benefits?

Well, that’s the thing. A «2 kinds of people in the world» sort of thing. Suppose the politicians declare that 7 is no longer a digit (don’t laugh, it could happen). There are going to be two kinds of reactions to this news:

1) People who want to go along with it. Who want to be kept appraised of the latest changes.

2) People who want their code to continue to work predictably, ignoring the whims of the pols.

I’m in group 2.
(Even though most people are in group 1)

Poster of inconvenient truths.

Back from a short, unplanned vacation. Did you miss me?



Return to “Beginners”

Понравилась статья? Поделить с друзьями:
  • Await outside function как исправить
  • Avtl 104 ошибка f01
  • Avtf 104 ошибка h20
  • Avs video recorder ошибка 105
  • Avs 500p стабилизатор ошибка l