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…
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",…
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…
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…
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…
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…
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 …
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…
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…
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…
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"…
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…
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…
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…
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…
AkD
  • 161
  • 3
1 2 3
8 9