There are some parts of Linux shell file programming that I don't understand.

Asked 2 years ago, Updated 2 years ago, 57 views

It's very basic, so I have no idea what's wrong.

test.sh
#!/bin/bash

echo "TEST START !!"

VAL = `ps -ef | tail -3`
echo "$VAL"
 Execution result
TEST START !!
./test.sh: 5: ./test.sh: VAL: not found

Is there anything wrong with the code?

shell linux ubuntu bash

2022-09-21 16:57

1 Answers

VAL=`ps -ef | tail -3`

You must paste the assignment statement without spacing. Shell scripts were created so long ago that there are a lot of things that you shouldn't look at as common sense in general programming languages.


2022-09-21 16:57

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.