Search Results

Search: Posts Made By: pankai
5,962
Posted By pankai
How to change parent shell's variables?
I have a question about how to change variables in parent shell.

My script, test.sh, is below:

#!/bin/sh
# test.sh
PATH=.

The commands I ran for test:

$ echo $PATH...
2,785
Posted By pankai
The command list string is inputed by the user,...
The command list string is inputed by the user, and the script is supposed to run it.
Anyway, I found a workaround by running each command separately:

command="ls abc; ls $HOME"

while...
2,785
Posted By pankai
how to get status array for the commands in eval
I want to get a status code array for the commands in eval.

For example,
eval "ls abc; ls def; ls $HOME"

I want to get the status code for each ls command in eval. Is there any way to make...
20,722
Posted By pankai
I did some research myself. I turned out that we...
I did some research myself. I turned out that we can get the status code for each command in a pipeline from $PIPESTATUS array.
20,722
Posted By pankai
How to get exit code in a pipe-lined command?
I have a question about how to get the exit code of the first command when it appears in a pipe-lined command.
For example, I have the following script:

grep abc dddd | tee -a log
if [[ $? -ne...
18,342
Posted By pankai
run commands from a variable
I have a question of how to run commands from a variable where there are more than one commands in the variable under bash.

I ran the following commands under bash

> command="ls /etc/zshrc; ls...
21,730
Posted By pankai
drl, thanks!
drl, thanks!
86,520
Posted By pankai
Just replied to a wrong thread.
Just replied to a wrong thread.
21,730
Posted By pankai
how to keep newline characters in command execution result?
I found that when I used a variable to receive the result from a command execution, the newline characters were removed from the variable.

For example, I ran

$ ret=`ls -l`
$ echo $ret

Then,...
3,358
Posted By pankai
Got it. Thanks.
Got it. Thanks.
3,358
Posted By pankai
weird behavior of grep -P
I met a problem in using grep -P.

There is a text file, temp.txt, whose content is:
dddd
abc

I ran the command:

grep -P "\s*abc" temp.txt

The result I expected is:
abc

But, the...
37,108
Posted By pankai
Thanks all! Perderabo: very nice script. ...
Thanks all!

Perderabo: very nice script.

porter: I wrote a C program using the readline library, but I still don't know how to put the default value after the prompt so the user can edit on...
37,108
Posted By pankai
Thanks all! Perderabo: very nice script. ...
Thanks all!

Perderabo: very nice script.

porter: I wrote a C program using the readline library, but I still don't know how to put the default value after the prompt so the user can edit on...
37,108
Posted By pankai
In bash, read to a variable with a default value to edit
My script needs to read a variable from the user. But before the user types the input, I want to give a default value so the user can edit the default value for input.

How can I implement it?
...
Showing results 1 to 14 of 14

 
All times are GMT -4. The time now is 01:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy