Linuxのcppコマンドで#から始まる行を出力しない方法

このQ&Aのポイント
  • Linuxのcppコマンドで、ファイルの内容を出力する際に、最初の三行(行頭に'#'がある)を出力しない方法を知りたい。
  • cppコマンドのヘルプを見たが、該当するオプションが見つからなかった。
  • cppコマンドのバージョンは4.7.2であり、フリーソフトウェアである。
回答を見る
  • ベストアンサー

Linuxのcppコマンド、最初の#...を無く

ファイル<abc.txt>の内容が以下で、 1 2 3 /* 4 5 6 */ 次の命令を実行すると $ cpp abc.txt 以下の結果を得ます。 # 1 "abc.txt" # 1 "<command-line>" # 1 "abc.txt" 1 2 3 この、最初の三行(行頭に'#'がある)を、出力しないように出来ないでしょうか。 cppのヘルプを見ましたが、理解できなかったです。 バージョンです: cpp (Debian 4.7.2-5) 4.7.2 Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ヘルプです: Usage: cpp [options] file... Options: -pass-exit-codes Exit with highest error code from a phase --help Display this information --target-help Display target specific command line options --help={common|optimizers|params|target|warnings|[^]{joined|separate|undocumented}}[,...] Display specific types of command line options (Use '-v --help' to display command line options of sub-processes) --version Display compiler version information -dumpspecs Display all of the built in spec strings -dumpversion Display the version of the compiler -dumpmachine Display the compiler's target processor -print-search-dirs Display the directories in the compiler's search path -print-libgcc-file-name Display the name of the compiler's companion library -print-file-name=<lib> Display the full path to library <lib> -print-prog-name=<prog> Display the full path to compiler component <prog> -print-multiarch Display the target's normalized GNU triplet, used as a component in the library path -print-multi-directory Display the root directory for versions of libgcc -print-multi-lib Display the mapping between command line options and multiple library search directories -print-multi-os-directory Display the relative path to OS libraries -print-sysroot Display the target libraries directory -print-sysroot-headers-suffix Display the sysroot suffix used to find headers -Wa,<options> Pass comma-separated <options> on to the assembler -Wp,<options> Pass comma-separated <options> on to the preprocessor -Wl,<options> Pass comma-separated <options> on to the linker -Xassembler <arg> Pass <arg> on to the assembler -Xpreprocessor <arg> Pass <arg> on to the preprocessor -Xlinker <arg> Pass <arg> on to the linker -save-temps Do not delete intermediate files -save-temps=<arg> Do not delete intermediate files -no-canonical-prefixes Do not canonicalize paths when building relative prefixes to other gcc components -pipe Use pipes rather than intermediate files -time Time the execution of each subprocess -specs=<file> Override built-in specs with the contents of <file> -std=<standard> Assume that the input sources are for <standard> --sysroot=<directory> Use <directory> as the root directory for headers and libraries -B <directory> Add <directory> to the compiler's search paths -v Display the programs invoked by the compiler -### Like -v but options quoted and commands not executed -E Preprocess only; do not compile, assemble or link -S Compile only; do not assemble or link -c Compile and assemble, but do not link -o <file> Place the output into <file> -pie Create a position independent executable -shared Create a shared library -x <language> Specify the language of the following input files Permissible languages include: c c++ assembler none 'none' means revert to the default behavior of gu

質問者が選んだベストアンサー

  • ベストアンサー
  • notnot
  • ベストアンサー率47% (4848/10262)
回答No.1

cpp --help には何故か書いてませんね。man cpp には載ってます。 cpp -P abc.txt

remokon
質問者

お礼

返答ありがとうございます man cppってあるんですね。 解決しました。 今後もおねがいします

関連するQ&A

  • Intel C++ Compiler(Linux版)をインストールできない。

    Intel C++ Compiler 9.0 (Linux版)をインストールすることができません。 install.shを実行して、ライセンスファイルを指定したあとインストールが始まるとすぐに、 ./.././install_cc.sh: line 1272: ERROR: unable to find command "ls" !: command not found ./.././install_cc.sh: line 1276: Please add the location to the above commands to your PATH and re-run the script.: command not found ./.././install_cc.sh: line 1277: Please press Enter to continue...: command not found というエラーが出てしまいます。 lsコマンドが見つからないと書いてあるようですが、コンソールでlsコマンドは使えますし、PATHに/binも入っています。 どうしたらインストールすることができるのでしょうか? よろしくお願いします。

  • 修辞疑問--What would I not do

    ●What would I not do to help you both out of the trouble? (お2人をお助けするためならどんなことでもします) What would I not do to-不定詞 → 「~するためには私は何をしないだろうか→~するためには私は何でもする」 ところで、なぜこの文は What wouldn't I do to ~ と言わないのですか?

  • Ruby 暗号化したファイルの復号について

    Rubyでファイルを暗号化し、それを復号したいのですがうまくいかないため、 質問させていただきます。 Ruby 1.9.3を使用しています。 ・ファイルの暗号化 encrypt.rb ------------------------------------------------- # encoding: cp932 require 'openssl' def encrypt(file, pass)   enc = OpenSSL::Cipher::AES256.new('CBC')   enc.encrypt   enc.pkcs5_keyivgen(pass)   File.open(file, 'rb') do |fin|     File.open("#{file}.sec", 'wb') do |fout|       while buff = fin.read(8000)         fout.write(enc.update(buff))       end       fout.write(enc.final)     end   end   enc.reset end if $*.length > 0   print 'password: '   pass = $stdin.gets.chomp   $*.each do |arg|     begin       encrypt(arg, pass)       puts "#{arg}を暗号化したファイル#{arg}.secを作りました。"     rescue       puts "#{arg}の暗号化に失敗しました。"     end   end   0.upto(pass.length - 1) do |i|     pass[i] = '\xff'   end end ------------------------------------------------- ・ファイルの復号 decrypt.rb ------------------------------------------------- # encoding: cp932 def decrypt(file, pass)   dec = OpenSSL::Cipher::AES256.new('CBC')   dec.decrypt   dec.pkcs5_keyivgen(pass)   File.open(file, 'rb') do |fin|     File.open("#{file}.plain", 'wb') do |fout|       while buff = fin.read(512)         fout.write(dec.update(buff))       end       fout.write(dec.final)     end   end   dec.reset end if $*.length > 0   print 'password: '   pass = $stdin.gets.chomp   $*.each do |arg|     begin       decrypt(arg, pass)       puts "#{arg}を復号したファイル#{arg}.plainを作りました。"     rescue       puts "#{arg}の復号に失敗しました。"     end   end   0.upto(pass.length - 1) do |i|     pass[i] = '\xff'   end end ------------------------------------------------- コマンドプロンプトでencrypt.rb自身を暗号化し、encrypt.rb.secの作成はできるのですが、 decrypt.rbを実行してパスワードを入力しても復号ができません。 どのようにすれば復号できるのか教えていただけますでしょうか。

    • ベストアンサー
    • Ruby
  • 和訳をおねがいします

    こんにちは ある技術文書の抜粋です You can use the -fomit-frame-pointer option to make the compiler not save, frame-pointer はフレームポインタですが、fomit の意味はわかりませんでした option は、おそらくオプションだと思います compiler はコンパイラというものです よろしくお願いします

  • ターミナルのコマンド"man"

    Developer Toolsをインストールし、最初の頃は $ man 3 printf などと入力すればprintfの説明が表示されていたのですが、今は以下のようなエラーでマニュアルが表示されません。 sh: line 1: lv: command not found man: No such file or directory Failed to open the message catalog man on the path NLSPATH=<none> Error executing formatting or display command. System command (cd /usr/share/man && /usr/bin/tbl /usr/share/man/man3/printf.3 | /usr/bin/groff -Wall -mtty-char -Tascii -mandoc -c | lv) exited with status 32512. No entry for printf in section 3 of the manual 実際に/usr/share/man/man3/printf.3というファイルや、その他の関数に関するファイルは存在しています。 再度Developer Toolsをインストールしても改善されませんでした。 $ man manなどもエラーになります。 元のようにマニュアルを参照できるようにするにはどうしたらよいのでしょうか。

    • ベストアンサー
    • Mac
  • "what would I not do"のnot

    What would I not do to help her? という文で "what would I not do"のnotの位置なんですが "what woudn't I do"ではないのでしょうか?なぜここにnotが来れるのか解りません。 「彼女を助けるためにしないことがあろうか(いや、ない)」という意味なのは解ります。 解る方宜しくお願いします!

  • 英訳を宜しくお願いします。

    英訳を宜しくお願いします。 Not everyone has social skills, nor do they have the ability to see the back of their head without some help. 下記の英訳をしましたが、ひどいので訂正をお願いします。 『誰もが社交性ももっているわけでもなく、また助けなしに自分の頭の後ろを見る能力ももっていない。』 注意点は下記でよろしいでしょうか? (1)not ~nor~ =~もまた~ない (2)nor の後のdo は、強調のdoでしょうか? (3)back of their headがうまく訳せません。 どうぞ宜しくお願いします。

  • able toの関係代名詞的用法

    We need to help elderly people who are not able to do household works. というような文章を、 We need to help elderly people, able to do household works. というように略して書いてある文章を見かけるのですが このような用法って正しかったでしょうか? どうやって検索すれば正しいかどうか分かりますか?

  • 自作PCで最初に繰り返し表示されるBIOS画面

    ------------------------------------------------------------ SATA is found running at IDE MODE! SETUP option is available to set SATA to AHCH mode Now is IDE mode,the system can not support Hot Plug Would you chang the mode Y/N? **************************************** Do you want BIOS to enable this option for you? Y: Yes,set SATA to AHCI mode for me N: No,do not show this message again Any key: という画面が毎回PCを起動するたびに表示されます。 以前に"Y"を押したらBIOSの画面が繰り返し表示されてWindowsが起動できなくなりました。CMOSクリアで元に戻したのですが、この毎回表示される画面、どのようにすればよいのでしょうか?

  • j2sdk-1_4_2_15-linux-i586-rpm.binインストールできません。

    ご存知の方いらっしゃいましたらj2sdk-1_4_2_15-linux-i586-rpm.binのインストール時のエラー対処方法教えてもらえませんでしょうか。 環境は、Redhat linux ES4.5です。 /usr/localへ移してchmod 755 に変更し、 . j2sdk-1_4_2_15-linux-i586-rpm.bin を実行しました。 以前はこのやり方でインストールできましたが、ライセンスの同意箇所でyes [enter]すると、以下のメッセージが表示されてインストールできません。 =========== 途中略 ============== Do you agree to the above license terms? [yes or no] yes Unpacking... tail: オプションが違います -- b 詳しくは `tail --help' を実行して下さい. Checksumming... 1 The download file appears to be corrupted. Please refer to the Troubleshooting section of the Installation Instructions on the download page for more information. Please do not attempt to install this archive file. ==================================== しかもrootから一般ユーザに勝手に戻ってしまいます。 詳しい方教えていただけませんでしょうか。 宜しくお願い致します。