Comprehensive List of GSAR Commands with Descriptions - Printable Version +- WildlandsTech (https://wildlandstech.com) +-- Forum: Programming (https://wildlandstech.com/forumdisplay.php?fid=3) +--- Forum: Batch & Shell Scripting (https://wildlandstech.com/forumdisplay.php?fid=42) +--- Thread: Comprehensive List of GSAR Commands with Descriptions (/showthread.php?tid=148) |
Comprehensive List of GSAR Commands with Descriptions - Sneakyone - 09-03-2024 Comprehensive List of GSAR Commands with Descriptions **GSAR** (Global Search And Replace) is a command-line utility used for performing search and replace operations on binary and text files. Below is a detailed list of GSAR commands, along with descriptions and examples. 1. Basic Search and Replace Description: Replaces all occurrences of a specified search string with a replacement string in a file. Code: gsar -s"search_string" -r"replacement_string" [file] Code: gsar -s"foo" -r"bar" example.txt 2. Case-Insensitive Search and Replace Description: Replaces all occurrences of a search string with a replacement string, ignoring the case. Code: gsar -i -s"search_string" -r"replacement_string" [file] Code: gsar -i -s"foo" -r"bar" example.txt 3. Replace First Occurrence Only Description: Replaces only the first occurrence of the search string in the file. Code: gsar -o -s"search_string" -r"replacement_string" [file] Code: gsar -o -s"foo" -r"bar" example.txt 4. Replace and Create a Backup of the Original File Description: Replaces all occurrences of a search string and creates a backup of the original file. Code: gsar -b -s"search_string" -r"replacement_string" [file] Code: gsar -b -s"foo" -r"bar" example.txt 5. Search and Replace with a Specific Offset Description: Starts the search and replace operation at a specified byte offset within the file. Code: gsar -s"search_string" -r"replacement_string" -o[byte_offset] [file] Code: gsar -s"foo" -r"bar" -o100 example.txt 6. Search and Replace in a Specific Range Description: Replaces occurrences of a search string within a specified byte range in the file. Code: gsar -s"search_string" -r"replacement_string" -n[start_offset] -m[end_offset] [file] Code: gsar -s"foo" -r"bar" -n100 -m200 example.txt 7. Show Matching Lines Only (Silent Mode) Description: Shows only the lines that contain the matching search string, without modifying the file. Code: gsar -s"search_string" -r"replacement_string" -I [file] Code: gsar -s"foo" -r"bar" -I example.txt 8. Count the Number of Replacements Description: Displays the number of replacements made in the file. Code: gsar -s"search_string" -r"replacement_string" -c [file] Code: gsar -s"foo" -r"bar" -c example.txt 9. Replace with a Binary String Description: Replaces a search string with a binary sequence in the file. Code: gsar -s"search_string" -r"\x[hex_value]" [file] Code: gsar -s"foo" -r"\x0A" example.txt 10. Replace Using Hexadecimal Search and Replace Strings Description: Uses hexadecimal values for both the search and replace strings. Code: gsar -s"\x[search_hex]" -r"\x[replace_hex]" [file] Code: gsar -s"\x666F6F" -r"\x626172" example.txt 11. Replace with Confirmation Description: Prompts the user for confirmation before replacing each occurrence. Code: gsar -s"search_string" -r"replacement_string" -p [file] Code: gsar -s"foo" -r"bar" -p example.txt 12. Invert Match (Replace Non-Matching Lines) Description: Replaces lines that do not match the search string. Code: gsar -v -s"search_string" -r"replacement_string" [file] Code: gsar -v -s"foo" -r"bar" example.txt 13. Use Regular Expressions for Search and Replace Description: Uses regular expressions for more advanced search and replace operations. Code: gsar -r"regex_search" -r"regex_replace" [file] Code: gsar -r"\d+" -r"number" example.txt 14. Perform a Dry Run (No Changes Made) Description: Simulates the search and replace operation without making any changes to the file. Code: gsar -s"search_string" -r"replacement_string" -t [file] Code: gsar -s"foo" -r"bar" -t example.txt 15. Display Help Information Description: Displays help information for the GSAR command, listing all available options and their descriptions. Code: gsar -h Code: gsar -h Conclusion The **GSAR** command is a powerful utility for performing search and replace operations in binary and text files. By mastering these commands, you can efficiently manipulate and modify file contents, whether for data processing, text manipulation, or binary file editing. Happy Editing! |