Skip to main content

All Questions

1 vote
6 answers
668 views

Bash script that takes multiple path arguments and checks if files can be successfully created there

I would like a bash shell script (for my Debian 12 system) which accepts multiple paths as arguments, and then checks if a file can be successfully created in each one. Then the result should be put ...
teeeeee's user avatar
  • 293
0 votes
2 answers
115 views

Processing a specific part of a text according to pattern from AWK script

Im developing a script in awk to convert a tex document into html, according to my preferences. #!/bin/awk -f BEGIN { FS="\n"; print "<html><body>" } # ...
Francisco de Javier's user avatar
0 votes
1 answer
112 views

How to create a sh script that can give as output the exact string I want using the awk command [duplicate]

I would like to have some help writing a script (which should work on FreeBSD where I have sh as default) that should grab a precise string when I do a ps ax | grep bhyve command from the terminal. ...
Marietto's user avatar
  • 579
0 votes
0 answers
17 views

How to returns the correct character after manipulating the output of ps ax | grep [duplicate]

I would like to have some help writing a script (which should works on freebsd where I have sh as default) that should grab a precise character when I do a "ps ax | grep" command from the ...
Marietto's user avatar
  • 579
0 votes
2 answers
2k views

Parsing CSV with AWK, returning fields to bash var with line breaks

I have to migrate a password database (Keepass) by using a csv file of it, to a new application by using its API. The API is updated with post requests, those needs JSON data format. What I need to do ...
Plourfi's user avatar
0 votes
1 answer
282 views

Can't make awk loop over file values

Hi guys I'm trying to loop over the values of a file (or multiple files) passed as a parameter to the script as in, ./myscript file1 file2 ... but awk only recognizes the first line of each file. #!/...
arlugones's user avatar
1 vote
1 answer
761 views

How to find the standard deviation of values in a file using awk to parse 500 files at once?

I have 500 files each with a column of values I need to find the standard deviations for. I've figured out this much: awk '{sum+=$5; array[NR]=$5} END {for(x=1;x<=NR;x++){sumsq+=((array[x]-(sum/NR))...
alby's user avatar
  • 11
-3 votes
1 answer
95 views

Calculating the average area of the states listed in states.txt [closed]

Need someone to calculate the average area, in square miles, of the states listed in states.txt. States.txt (file): State Population SqMi Region --------------------------------------...
Jimmy Gonzalez's user avatar
0 votes
6 answers
2k views

Remove spaces till the end of each line for each line in a file

I am trying to remove the spaces from each line till the last word for each line in a file. Example input file: 808 0 C01124 Amazon 45/234Birch 00 YYY 808 0 ...
Amin's user avatar
  • 13
0 votes
1 answer
2k views

finding the highest character length in each column using a loop and awk

I am trying to create a script that goes through a document and finds the highest character length in a column and return it. This script returns 78,78,78,78 when, what im aiming for is 10,11,14,51 ...
user419771's user avatar
1 vote
3 answers
2k views

Extracting numbers between two string patterns

I have a file with following type of expression in every line "Age=22 years and Height=6 feet", I want to extract Age and height numbers only. I have tried grep -oP '(?<=Age=)[^years]+' $...
user3696623's user avatar
0 votes
2 answers
134 views

how to put all directory tags into different variables

I have fetched all the directory tags from a file. Now, I am stuck in a situation where I want to store that whole individual directory tags in to different variables as shown below. Thanking in ...
Taha Tikiwala's user avatar
1 vote
4 answers
186 views

Separate multiple sections/lines from a file

I have a file with below sample texts: THIS( is first Line); THAT( is second line); THIS( is third line); THAT( is fourth line); If you see the file, each sections are either starts with "THIS" or "...
dev's user avatar
  • 11
2 votes
2 answers
5k views

Display only IP addresses from nslookup without writing output to file

i am a student newly studying cybersecurity. We are using kali linux for the phases of pen-testing. I'm new to bash script too. Command: nslookup -type=mx cathay.com.sg EXAMPLE OUTPUT Server: ...
inglfur's user avatar
  • 21
-1 votes
1 answer
475 views

Check if a two columns are completely numeric in a csv using awk

I have a csv with columns A & B as below which has numeric or alphanumeric data.I need to write column C such that if, A or B is blank -> write "Error" in C A or B not numeric -> write "Error" ...
Chethan S G's user avatar

15 30 50 per page