Linux

Hammer script to get output from Job by id

This is a simple script I use to export the details from a Job run in Red Hat Satellite 6.2 using hammer from the console. #!/bin/bash # Redhat Satellite Job query by id using hammer if [ $1 -eq $1 ] 2>/dev/null; then # get hosts run by ID JOBHOSTS=$(hammer job-invocation info –id $1 | […]

Read More
Linux

Generate IP-address ranges using simple bash script

This is just a simple script to generate IP-addresses in a IP-range and write the result output to a file. The script does also remove addresses you would like to exclude from the final output. #!/bin/bash OUTFILE=”mk-iprange.txt” IPRANGE=”192.168.0 192.168.1″ EXCLUDE=”192.168.0.1 192.168.0.2 192.168.1.1″ # Remove old OUTFILE rm -f $OUTFILE # Loop addresses, write to OUTFILE […]

Read More
Linux

Another way to randomize filenames

This post describes an easier way to randomize filenames using the command openssl compared to my previous post named Randomize filenames. #!/bin/bash for filename in *.JPG do mv “$filename” $(echo “$filename” | openssl rand -hex 3).JPG done After running this script the filenames can look something like this 26333c.JPG a8c7a0.JPG b16b22.JPG d69a67.JPG … The rand […]

Read More
Scripting

Create random filenames with random content

I wanted to test filesystem checking on a large XFS filesystem and needed to fill the filesystem. The task was to create files on random with different file size and names placed in different folders. The script I found on the Internet does exactly that #!/bin/bash # Created by Ben Okopnik on Wed Jul 16 […]

Read More
Linux

Script to delete files listed in a file

This is a short one liner bash script to delete files in a file. The script also handles filenames with space in them. $ while read file; do rm “$file”; done < filename.txt To generate a filename.txt file by searching for a specific pattern you can use the following command $ find / -type f […]

Read More