当前位置:网站首页>Assign the output of a command to a variable [repeat] - assigning the output of a command to a variable [duplicate]
Assign the output of a command to a variable [repeat] - assigning the output of a command to a variable [duplicate]
2022-07-05 22:17:00 【Technology feast】
problem :
I am new with unix and I am writing a shell script. I am a unix Novice , Writing a shell Script .
When I run this line on the command prompt, it prints the total count of the number of processes which matches: When I run this line at the command prompt , It will print the total number of matching processes :
ps -ef | awk '/siebsvc –s siebsrvr/ && !/awk/ { a++ } END { print a }'
example, the output of the above line is 2 in the command prompt. for example , The output of the above line at the command prompt is 2.
I want to write a shell script in which the output of the above line (2) is assigned to a variable, which will be later be used for comparison in an if statement. I want to write one shell Script , Among them, paragraph (2) The output of the row is assigned to a variable , This variable will be used later in if Statement .
I am looking for something like I'm looking for something similar
output= `ps -ef | awk '/siebsvc –s siebsrvr/ && !/awk/ { a++ } END { print a }'`echo $output
But when i run it, it says output could not be found whereas I am expecting 2. Please help. But when I run it , It says the output cannot be found , And I expect 2. Please help .
Solution :
Reference resources : https://stackoom.com/en/question/1Oo2K边栏推荐
- 等到产业互联网时代真正发展成熟,我们将会看待一系列的新产业巨头的出现
- Technology cloud report: how many hurdles does the computing power network need to cross?
- 科技云报道:算力网络,还需跨越几道坎?
- Regular expressions and re Libraries
- Leetcode simple question ring and rod
- The difference between MVVM and MVC
- 2022软件测试工程师涨薪攻略,3年如何达到30K
- How to quickly experience oneos
- Learning of mall permission module
- 344. Reverse String. Sol
猜你喜欢
EBS Oracle 11g cloning steps (single node)
What if win11 is missing a DLL file? Win11 system cannot find DLL file repair method
Index optimization of performance tuning methodology
Promql demo service
AD637使用筆記
"Chris Richardson microservices series" uses API gateway to build microservices
数据泄露怎么办?'华生·K'7招消灭安全威胁
Win11缺少dll文件怎么办?Win11系统找不到dll文件修复方法
A substring with a length of three and different characters in the leetcode simple question
元宇宙中的三大“派系”
随机推荐
Overriding equals() & hashCode() in sub classes … considering super fields
Metaverse Ape猿界应邀出席2022·粤港澳大湾区元宇宙和web3.0主题峰会,分享猿界在Web3时代从技术到应用的文明进化历程
Serializability of concurrent scheduling
A number of ventilator giants' products have been recalled recently, and the ventilator market is still in incremental competition
Pinctrl subsystem and GPIO subsystem
Understand the basic concept of datastore in Android kotlin and why SharedPreferences should be stopped in Android
[Yugong series] go teaching course 003-ide installation and basic use in July 2022
装饰器学习01
AD637使用筆記
What if win11 is missing a DLL file? Win11 system cannot find DLL file repair method
MySQL连接断开报错MySQLdb._exceptions.OperationalError 4031, The client was disconnected by the server
Leetcode simple question check whether all characters appear the same number of times
ESP32 hosted
Sub total of Pico development
Leetcode simple question: check whether each row and column contain all integers
Livelocks and deadlocks of concurrency control
The difference between MVVM and MVC
MySQL服务莫名宕机的解决方案
Leetcode simple question: find the nearest point with the same X or Y coordinate
Some tutorials install the database on ubantu so as not to occupy computer memory?