当前位置:网站首页>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 $outputBut 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边栏推荐
- Win11 runs CMD to prompt the solution of "the requested operation needs to be promoted"
- Wonderful review of the digital Expo | highlight scientific research strength, and Zhongchuang computing power won the digital influence enterprise award
- 如何開發引入小程序插件
- Summary of concurrency control
- K210学习笔记(四) K210同时运行多个模型
- Three "factions" in the metauniverse
- Oracle triggers
- C language knowledge points link
- Reptile practice
- Go语言学习教程(十五)
猜你喜欢

Nacos installation and service registration

Granularity of blocking of concurrency control

Livelocks and deadlocks of concurrency control

Interprocess communication in the "Chris Richardson microservice series" microservice architecture

A substring with a length of three and different characters in the leetcode simple question

Reptile practice

Oracle triggers

K210学习笔记(四) K210同时运行多个模型

Practice: fabric user certificate revocation operation process

700. Search in a Binary Search Tree. Sol
随机推荐
Common interview questions of redis factory
Implementation technology of recovery
Wonderful review of the digital Expo | highlight scientific research strength, and Zhongchuang computing power won the digital influence enterprise award
Business learning of mall commodity module
FBO and RBO disappeared in webgpu
2022-07-05:给定一个数组,想随时查询任何范围上的最大值。 如果只是根据初始数组建立、并且以后没有修改, 那么RMQ方法比线段树方法好实现,时间复杂度O(N*logN),额外空间复杂度O(N*
Blocking of concurrency control
U盘的文件无法删除文件怎么办?Win11无法删除U盘文件解决教程
The statistics of leetcode simple question is the public string that has appeared once
Countdown to 92 days, the strategy for the provincial preparation of the Blue Bridge Cup is coming~
Interview questions for famous enterprises: Coins represent a given value
【愚公系列】2022年7月 Go教学课程 004-Go代码注释
[Chongqing Guangdong education] National Open University autumn 2018 0088-21t Insurance Introduction reference questions
Pinctrl subsystem and GPIO subsystem
Go语言学习教程(十五)
"Chris Richardson microservices series" uses API gateway to build microservices
The difference between MVVM and MVC
How to reverse a string fromCharCode? - How to reverse String. fromCharCode?
Nacos installation and service registration
科技云报道荣膺全球云计算大会“云鼎奖”2013-2022十周年特别贡献奖