Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

dosy2unix_ctrl_ultra 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/usr/bin/bash
  2. # #!/usr/bin/tcsh
  3. # file: dos2unix1
  4. #
  5. # Synopsis: THIS IS A VARIANT OF dos2unix
  6. # where you want to replace a dos file by a unix file!
  7. # So, you give it only ONE file argument:
  8. #
  9. # > dos2unix1 filename
  10. #
  11. # As a result, filename is converted from a dos file
  12. # into a unix file.
  13. #
  14. #############################################################
  15. # How do you convert a dos file to unix?
  16. #############################################################
  17. # Well, gvim sometimes could do it, but it is sometimes too clever
  18. # and it hides the extra dos characters from view! Then you cannot
  19. # delete these characters. [I am not sure how to turn off this
  20. # cleverness of gvim]
  21. #
  22. # But do you really care if they don't show up on gvim?
  23. # Here is one case where it matters: I have two files, foo and bar,
  24. # that I need to diff. If one is in unix and other in dos format,
  25. # then diff does not produce anything sensible!
  26. #
  27. # A web search gave a number of solutions (e.g., use ftp, etc).
  28. # Here is one I like, based on the program "tr" which translates
  29. # or deletes characters from standard input to standard output!
  30. # This is available on cygwin!
  31. #
  32. # SYNOPSIS of tr:
  33. #
  34. # tr [OPTION]... SET1 [SET2]
  35. #
  36. # -c, --complement
  37. # first complement SET1
  38. #
  39. # -d, --delete
  40. # delete characters in SET1, do not translate
  41. #
  42. # -s, --squeeze-repeats
  43. # replace sequence of characters with one
  44. #
  45. # -t, --truncate-set1
  46. # first truncate SET1 to length of SET2
  47. #
  48. # --help display this help and exit
  49. #
  50. # SETs are specified as strings of characters. Most represent them-
  51. # selves. Interpreted sequences are:
  52. #
  53. # \NNN character with octal value NNN (1 to 3 octal digits)
  54. #
  55. # \\ backslash
  56. #
  57. # \a audible BEL
  58. #
  59. # \b backspace
  60. #
  61. # \f form feed
  62. #
  63. # ...etc
  64. #############################################################
  65. # The upshot:
  66. # The following line can be used to remove all carriage returns
  67. # and Ctrl-z (^Z) characters from a DOS file by typing:
  68. #
  69. # > tr -d '\15\32' < dosfile.txt > unixfile.txt
  70. # Here is the automation via shell script:
  71. #
  72. tr -d '\000-\011\013\014\016-\037\174' < $1 > $1.yaptemp
  73. mv $1.yaptemp $1
  74. #############################################################
  75. # The downside:
  76. # tr cannot be used to convert a document from
  77. # Unix format to DOS.
  78. #############################################################