Questions tagged [unix-shell]

130 questions
2
votes
0 answers

How to enable logging of commands run through shell script in ESXi Hypervisor?

On ESXi Hypervisor, If I run a command on the terminal via SSH, the commands are logged in the shell.log file, i.e if i run this command [root@esxi04:~] ls -la then I can see this command in shell.log file as: <164>2023-02-22T09:34:24.337Z test_host…
Cool Guy
  • 21
  • 1
2
votes
2 answers

Make a gzip-compressed tar archive of files and directories that have a specific letter

I want ONLY directories and files that contain the letter. I've been able to recreate it from a previous question. But the tar is not a gzip. And when trying to make it a gzip it...doesn't remove leading ´/' from hard link targets? which ruins…
Zweks
  • 23
  • 3
2
votes
2 answers

Skeleton files /etc/skel/ automatic syncing of changes to all users

Linux distributions place some important scripts and config files in the skeleton, from where they are copied to each new user's home directory. Ideally system-wide files would be used instead of anything automatically copied to home but this is not…
Tronic
  • 121
  • 3
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,187
  • 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
  • 1
  • 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
  • 579
  • 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
  • 448
  • 1
  • 5
  • 18
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
  • 7
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 2 3
8 9