Write a simple bash script that will go through all *.cpp files and will sort includes…
- User
Write a simple bash script that will go through all *.cpp files and will sort includes alphabetically.
Assistant
Here is a simple bash script that will go through all
.cppfiles in the current directory and sort the includes alphabetically:code#!/bin/bash # loop through all .cpp files in the current directory for file in *.cpp; do # sort the includes alphabetically sort -u -o "$file" < "$file" doneThis script uses the
forloop to iterate through all.cppfiles in the current directory, and then uses thesortcommand to sort the includes alphabetically, and overwrite the original file. The-uoption removes duplicates, and the-ooption specifies the output file.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.