All Questions
25
questions
0
votes
5
answers
558
views
How to dynamically change owner of directory using awk output?
What I want to do :
Takes user & their home directory list from /etc/passwd
use the username and home address as parameters and change ownership of those directory to that user.
Current outputs:
...
0
votes
1
answer
58
views
Embeded If with awk (filter output content)
I am running a few commands on a firewall then splitting up that log file into multiple smaller files. My data file MASA1 looks like this...
MASA1/pri/act# changeto context admin
MASA1/pri/act/...
0
votes
1
answer
6k
views
Read a json file and run a command in Bash
I wanna block a mac address which downloaded value is over "20480":
The json file:
{
"client_length": 3,
"clients": {
"ac:07:5f:77:40:e9": {
"id": 1,
"ip": "192.168.5.40",
...
3
votes
3
answers
792
views
How to grep data of a new line when capturing a keyword?
I have a file which contains below sample line having a common keyword P00001121 in each line.
[H00,P00001121] CHANNEL__OPEN:TCP_ADDRESS='10.32.130.202' TCP_PORT='80'"
[H00,P00001121] COMMS_QUEUING:...
1
vote
2
answers
145
views
selective deletion of lines between two patterns
I have a file which contains following content,
Hello world Unix!!
Its bright world
Current time is HH:mm:ss
Next action plan is item #3
End of task.
Thank you.
Hello world Linux!!
All actions ...
1
vote
1
answer
2k
views
How to parse openssl certificate output into hostname and verification codes?
I have this shell code that reads lines of host names from input file, performs an openssl command to print ssl certificate info, and outputs the results in the terminal.
while read x;
do
echo $x;
...
0
votes
3
answers
3k
views
How to insert a line into a crontab AFTER a key word or string via script
I understand there is a lot of documentation on editing crontabs via script, and I can do this by adding an entry with the following command:
line="* * * * * /my/folder/script.sh"
( crontab -l ; echo ...
0
votes
3
answers
2k
views
Bash: inserting output from `id` into print statement
I'm trying to achieve the following:
List my Linux users, that have set bin/bash in /etc/passwd AND append each user's info from id [username] into the print statement, something in the lines of:
cat ...
0
votes
2
answers
102
views
Compare two files with using awk
I have 2 files.
File 1 contains :-
emcas_biaas_dev=-628
emcas_brs_ba=-32
emcas_cc_analytics=246
emcas_edservices_bi=312
emcas_edservices_dev=-159
emcas_engr_usd=1519
emcas_engr_xio=-67
emcas_fin_bi=...
0
votes
3
answers
424
views
Bash script stops using variable with no reason
I'm stuck on this script. I've defined a variable with a single cat of a temp file, and these are the following operations done by the script.
PROJECT=$(cat temp/project_name_final) ;
#...
1
vote
2
answers
1k
views
How to extract the number of physical processors and threads per core? (No text, only the number to use as input elsewhere)
I want to use the number of cores in a script and I am not sure what is the best approach to extract the number itself.
For example, the below extracts the number of physical cores, however how ...
2
votes
2
answers
4k
views
Extracting text blocks based on grep output
I'm currently working with a text file that contains the following text blocks:
--------------------------------------
Beginning of block
Text
Random Text
keywordA
Text
End of block
------------------...
1
vote
1
answer
2k
views
Overwrite file using AWK in a for loop
I'm working on the following script:
!/bin/bash
FILE1=dispositivoss.csv
NUMERODISP="$(wc -l $FILE1 | awk '{print $1}')"
for (( c=2; c<=$NUMERODISP; c++ ))
do
IP=$(awk -vnum="$c" 'NR == ...
2
votes
1
answer
3k
views
Ideas for parsing netstat results for active connections
I have several remote devices that create reverse ssh connections back to my server, so that I ssh to them and manage them remotely. They connect back to me via a custom port. When I do a netstat -...
0
votes
1
answer
2k
views
Add info from .dat to .csv file
I have a text file like this:
sn,device_id,ip_address
P7K08UQ , BIOTERIO, 148.111.83.177
H006K022 , N7K-LAN(JAF1651ANDL), 148.111.4.111
FNS174002FT , LAB_PESADO, 148.111.131.188
...