Run Linux file processing commands in Windows

By | December 24, 2024

Sometime it is necessary to compress or expand gz or tar files, print the sequences of printable characters from binary files or something similar. There are terminal commands which do such operations in Linux but in Windows usually it is necessary to download in install extra tool. However it is Windows Subsystem for Linux permits to do it easily. There are several example below.

1. Search for ASCII sequences which contains word service in msedge.exe application:


:/mnt/c/Program Files (x86)/Microsoft/Edge/Application# strings msedge.exe | grep se
rvice
The service ticket is null.
download_service
service_manager
disabled-by-default-gpu.service
..\..\base\path_service.cc
Cannot enumerate running services.
service-sandbox-type
service
service_with_jit
asset_store_service
edge_windows_copilot_service
..\..\sandbox\win\src\broker_services.cc

2. Get property of wordpad.exe:


:/mnt/c/Program Files (x86)/Windows NT/Accessories# file wordpad.exe
wordpad.exe: PE32 executable (GUI) Intel 80386, for MS Windows, 6 sections

3. Compress text file to gz file:


:/mnt/c/Temp# gzip -c textfile.txt > textfile.gz
:/mnt/c/Temp# gzip -l textfile.gz
compressed uncompressed ratio uncompressed_name
825 18197 95.6% textfile

Leave a Reply

Your email address will not be published. Required fields are marked *