Skip to content

Tag: bash

Trimming string up to certain characters in Bash

I’m trying to make a bash script that will tell me the latest stable version of the Linux kernel. The problem is that, while I can remove everything after certain characters, I don’t seem to be able to delete everything prior to certain characters. Somehow the output “ignores” the wget…

why this code isn’t working in bash?

I am using tail -f to fetch log file and output of log this command is input to grep command with search for “ERROR” string and output of grep is used to create/write into a temporary file(tmpLog) . command : logfile content Issue is , i am not getting content in tmpLog file , although it is creat…

common profile to record ssh sessions

I need to be able to record all ssh sessions on my server. After fumbling around with pam.d auditd, I found this enter link description here. And it looks to be working pretty well. However, when you “clear” the screen, your session log gets wiped as well. Is is possible to open a new log file whe…

Error in code for parsing arguments

i learned bash very recently, and i’m trying to read arguments for my script. So i wrote this, but i get an error (and vim has highlited in pink the last double parenthesis in the 4th line) I get the following error when i run ./test -so doc1 Can anyone help me understand what’s wrong with my scri…

AWK: variables not remembered outside actions?

I have a script that will give the percent of logins that are mine. This is done by matching all users, store to variable, then match me only (jdoe). I then use a basic operation to get the percent of logins that are mine. I get the error: ./loginPercent: line 13: eCount / totalCount: division by 0 (error tok…