Skip to main content
Code Review

Return to Question

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

Inspired by Tool for creating CodeReview questions Tool for creating CodeReview questions.

This script generates a markdown document suitable for a CR question from a list of files. For each file it finds, it sends the following to stdout:

  • The relative path to the file, in bold.
  • The byte count and line count, in parentheses.
  • The contents of the file, indented four spaces on each line.

./mdproj.sh (186 bytes in 7 lines)

for path in $(find "$@"); do
 bytes="$(wc -c < "$path") bytes"
 lines="$(wc -l < "$path") lines"
 echo -e "\n**$path** ($bytes in $lines)\n"
 sed "s/^/ /" < "$path"
done

The script takes the same options as find. Example usage:

mdproj.sh -name *.h -or -name *.cpp > whatever.md

Update / known issues

  • No spaces, backquotes, backslashes, asterisks, or other weird characters are allowed in file names.

  • Watch out for shell expansion when invoking the script. Arguments should be enclosed in quotes in cases where the the shell would expand them.

Inspired by Tool for creating CodeReview questions.

This script generates a markdown document suitable for a CR question from a list of files. For each file it finds, it sends the following to stdout:

  • The relative path to the file, in bold.
  • The byte count and line count, in parentheses.
  • The contents of the file, indented four spaces on each line.

./mdproj.sh (186 bytes in 7 lines)

for path in $(find "$@"); do
 bytes="$(wc -c < "$path") bytes"
 lines="$(wc -l < "$path") lines"
 echo -e "\n**$path** ($bytes in $lines)\n"
 sed "s/^/ /" < "$path"
done

The script takes the same options as find. Example usage:

mdproj.sh -name *.h -or -name *.cpp > whatever.md

Update / known issues

  • No spaces, backquotes, backslashes, asterisks, or other weird characters are allowed in file names.

  • Watch out for shell expansion when invoking the script. Arguments should be enclosed in quotes in cases where the the shell would expand them.

Inspired by Tool for creating CodeReview questions.

This script generates a markdown document suitable for a CR question from a list of files. For each file it finds, it sends the following to stdout:

  • The relative path to the file, in bold.
  • The byte count and line count, in parentheses.
  • The contents of the file, indented four spaces on each line.

./mdproj.sh (186 bytes in 7 lines)

for path in $(find "$@"); do
 bytes="$(wc -c < "$path") bytes"
 lines="$(wc -l < "$path") lines"
 echo -e "\n**$path** ($bytes in $lines)\n"
 sed "s/^/ /" < "$path"
done

The script takes the same options as find. Example usage:

mdproj.sh -name *.h -or -name *.cpp > whatever.md

Update / known issues

  • No spaces, backquotes, backslashes, asterisks, or other weird characters are allowed in file names.

  • Watch out for shell expansion when invoking the script. Arguments should be enclosed in quotes in cases where the the shell would expand them.

edited tags
Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238
added 285 characters in body
Source Link
Dagg
  • 4.6k
  • 1
  • 25
  • 41

Inspired by Tool for creating CodeReview questions.

This script generates a markdown document suitable for a CR question from a list of files. For each file it finds, it sends the following to stdout:

  • The relative path to the file, in bold.
  • The byte count and line count, in parentheses.
  • The contents of the file, indented four spaces on each line.

./mdproj.sh (186 bytes in 7 lines)

for path in $(find "$@"); do
 bytes="$(wc -c < "$path") bytes"
 lines="$(wc -l < "$path") lines"
 echo -e "\n**$path** ($bytes in $lines)\n"
 sed "s/^/ /" < "$path"
done

The script takes the same options as find. Example usage:

mdproj.sh -name *.h -or -name *.cpp > whatever.md

Update / known issues

  • No spaces, backquotes, backslashes, asterisks, or other weird characters are allowed in file names.

  • Watch out for shell expansion when invoking the script. Arguments should be enclosed in quotes in cases where the the shell would expand them.

Inspired by Tool for creating CodeReview questions.

This script generates a markdown document suitable for a CR question from a list of files. For each file it finds, it sends the following to stdout:

  • The relative path to the file, in bold.
  • The byte count and line count, in parentheses.
  • The contents of the file, indented four spaces on each line.

./mdproj.sh (186 bytes in 7 lines)

for path in $(find "$@"); do
 bytes="$(wc -c < "$path") bytes"
 lines="$(wc -l < "$path") lines"
 echo -e "\n**$path** ($bytes in $lines)\n"
 sed "s/^/ /" < "$path"
done

The script takes the same options as find. Example usage:

mdproj.sh -name *.h -or -name *.cpp > whatever.md

Inspired by Tool for creating CodeReview questions.

This script generates a markdown document suitable for a CR question from a list of files. For each file it finds, it sends the following to stdout:

  • The relative path to the file, in bold.
  • The byte count and line count, in parentheses.
  • The contents of the file, indented four spaces on each line.

./mdproj.sh (186 bytes in 7 lines)

for path in $(find "$@"); do
 bytes="$(wc -c < "$path") bytes"
 lines="$(wc -l < "$path") lines"
 echo -e "\n**$path** ($bytes in $lines)\n"
 sed "s/^/ /" < "$path"
done

The script takes the same options as find. Example usage:

mdproj.sh -name *.h -or -name *.cpp > whatever.md

Update / known issues

  • No spaces, backquotes, backslashes, asterisks, or other weird characters are allowed in file names.

  • Watch out for shell expansion when invoking the script. Arguments should be enclosed in quotes in cases where the the shell would expand them.

Tweeted twitter.com/#!/StackCodeReview/status/475810335216369664
Source Link
Dagg
  • 4.6k
  • 1
  • 25
  • 41
Loading
lang-bash

AltStyle によって変換されたページ (->オリジナル) /