Questions tagged [unix-shell]
124 questions
2
votes
6 answers
Last command issued on a GNU/Linux box
Someone asked at the mailing list of my local LUG if there is any way of learning the last command issued on a GNU/Linux system.
We're talking last command in a system-wide fashion I guess. After reasoning for a while if you limit the set of…
![](../../users/profiles/32512.webp)
gnrfan
- 171
- 5
2
votes
3 answers
How to ls and know the target of symbolic links in one command line?
I need to get the folder contents in one command line, right now if I do stat or ls, it tells me file type is Symbolic Link but it doesn't tell me if it's a file or a folder.
I'm using this;
stat -c '{"name": "%n", "size": "%s",…
![](../../users/profiles/16715.webp)
Devrim
- 1,197
- 4
- 16
- 29
1
vote
3 answers
text processing linux using grep awk or anything else
I want to replace in this string Wed Apr 10 06:44:10 UTC 2019 all whitespaces with comma and along with that trim off UTC part.
What I have tried :
var1="Wed Apr 10 06:44:10 UTC 2019"
echo ${var// /,}
This gives all spaces removed but how to trim…
![](../../users/profiles/444665.webp)
Alex
- 172
- 1
- 1
- 8
1
vote
1 answer
Convert a raw email message to plain text in linux
I'm in the cur folder of a maildir store.
I want to cat a message .. pipe it to a command .. and have the body of the message spit out. Simple.
Example:
If its a mime message .. and there is a plaintext version .. show me the plaintext ..
If its an…
![](../../users/profiles/193148.webp)
DHW
- 53
- 8
1
vote
5 answers
bash script - print from line N to EOF
I want to be able to print the number of lines from bash as such:
Line number (as counted from the top) -> end of the file
It seems tail will only count lines from the bottom.
Does anyone know how to do this? Thanks.
I've tried the following
# Where…
![](../../users/profiles/16315.webp)
bobinabottle
- 569
- 2
- 7
- 19
1
vote
1 answer
Pass parameter from Local to Sudo user
Ok if subject is not clear i will explain my doubt.I have a shell script kept at my local user called (executeAdM.sh), and when i execute this script i am connecting to SUDO user by taking commands from instruction file.But when i execute this…
![](../../users/profiles/424335.webp)
Tushar Sharma
- 119
- 4
1
vote
1 answer
Linux Free Disk Space per Device
In my system, df -hT outputs something like this:
> df -hT
Sist. Arq. Tipo Tam. Usado Disp. Uso% Montado em
devtmpfs devtmpfs 1,9G 8,0K 1,9G 1% /dev
tmpfs tmpfs 1,9G 616K 1,9G 1% /dev/shm
tmpfs tmpfs …
![](../../users/profiles/108289.webp)
j4x
- 105
- 7
1
vote
1 answer
Can't get PID from backgrounded java job
The PID file for this statement is created but it is always empty. When running the shell with -x I see that $! empty, yet at the end the java job is left running in the background as desired. Why is the pid missing?
su - $USER -c "nohup java…
![](../../users/profiles/181952.webp)
Neil H Watson
- 450
- 1
- 5
- 17
1
vote
1 answer
Why is my awk sub command failing?
When I run
df -hl | grep '/dev/disk1' | awk '{sub(/%/, \"\");print $5}'
I'm getting the following error:
awk: syntax error at source line 1
context is
{sub(/%/, >>> \ <<< "\");}
awk: illegal statement at source line 1
I can't seem to find…
![](../../users/profiles/264013.webp)
KinsDotNet
- 197
- 7
1
vote
4 answers
how to compare two directories residing in two different servers
I have one requirement like...I need to write a shell script which will compare two directories residing in two different servers (server A and server B) and list out the discrepancies if found any. Ideally the file names, counts, size should be…
![](../../users/profiles/17089.webp)
Prasenjit Patra
- 61
- 2
- 3
- 4
1
vote
1 answer
curl is giving wrong result via ssh
Curl is working fine on the node itself:
[ec2-user@smokebase1 ~]$ curl -s -I --retry 3 --header 'Host: smoke-base.dev-test.com' localhost:8080/test/api/search?where=where%20%2Fxml%2Fitem%2Fcategory%20is%20not%20%27dog%25%27 | grep "HTTP/1.1 200 OK"…
![](../../users/profiles/220816.webp)
A_01
- 133
- 1
- 6
1
vote
1 answer
Sent command-line output as an arguments to other command
1) Here is the command to install special package (for example system/header)
#pkg install system/header
2) ALso we can install several packages
#pkg install system/header network/ssh package/rpm
3) Here is the command to show all available…
![](../../users/profiles/193459.webp)
pavelartlover
- 13
- 3
1
vote
1 answer
Error when using mv
I am receiving an error when trying to mv some files that really doesn't make sense. I receive this error:
mv: cannot move `thatDir' to a subdirectory of itself, `/usr/local/apache-tomcat-6.0.32/webapps/thatDir'
When running the following command…
![](../../users/profiles/147501.webp)
Inversus
- 123
- 5
1
vote
1 answer
How to combine files with unix cat command based on file name, then rename?
I have a bunch of CSV files in a directory like:
modfinalak_1.csv
modfinalal_1.csv
modfinalal_2.csv
modfinalal_3.csv
modfinalar_1.csv
modfinalar_2.csv
so it's one or multiple files per each US state (AK, AL, AR, etc.). How can I use cat to combine…
![](../../users/profiles/130778.webp)
tiredofcoding
- 13
- 4
1
vote
0 answers
runas or sudo equivalent on AS400 ibm iSeries (invoke it via java code)
Possible Duplicate:
“runas” or “sudo” equivalent on AS400 IBM iSeries
I am trying to invoke a program to run as another user(by getting input user/pwd) in AS400 OS using Java. Like runas in windows or sudo in unix, what can we do in AS400 OS?
I…
![](../../users/profiles/130605.webp)
AkD
- 161
- 3