View Linux find.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A find Tutorial and Primer: https://danielmiessler.com/study/find/ | |
find . -name '*.jpg' | |
# find only directories | |
find . -name 'foo' -type d | |
# find only files | |
find . -name 'foo' -type f |
View Linux create tarball.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tar cvf file.tar path | |
tar cvzf file.tar.gz path | |
tar cvjf file.tar.bz2 path |
View Linux show open ports.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo netstat -plnt |
View ImageMagick determine image format.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
identify -format '%[m]' file.jpg[0] |
View ImageMagick determine image dimensions.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
identify -format '%[fx:w]x%[fx:h]' file.jpg[0] |
View Golang filename without path.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"path/filepath" | |
) | |
func fileNameWithoutPath(fileName string) string { | |
return filepath.Base(fileName) | |
} |
View Golang filename without extension.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"strings" | |
"path/filepath" | |
) | |
func fileNameWithoutExtension(fileName string) string { | |
return strings.TrimSuffix(fileName, filepath.Ext(fileName)) | |
} |
View Golang filename directory.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "path" | |
func filenameDirectory(filename string) string { | |
return path.Dir(filename) | |
} |
View Golang determine image format.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func determineImageType(fileName string) (imageType string, err error) { | |
return runProgram1("identify", "-format", "%[m]", fmt.Sprintf("%v[0]", fileName)) | |
} |
View Golang determine image dimensions.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"strings" | |
"strconv" | |
"errors" | |
) | |
func determineImageDimensions(fileName string) (width, height uint64, err error) { |
NewerOlder