2

I have a list of file names like

./run_results/rat/coding_exons/0.01_100_best.txt ./run_results/mouse/introns/0.01_100_best.txt

I want to create new files with names like rat_coding_exons_0.01_100_best.txt or mouse_introns_0.01_100_best.txt

Problem is, when I try to cut these file names, cut instead starts cutting each line in said files (sensible, but not what I want).

2 Answers2

3

Instead of cut filename you want echo filename | cut (i.e. pass the filenames to cut as the input from stdin).

EightBitTony
  • 21,373
  • Works by itself, but when I pipe commands from find to echo it does not work. find . -name "*0.01*txt" | echo returns nothing so there is nothing for me to cut. That, however is not your fault so upvote. – The Unfun Cat Jun 23 '13 at 08:48
  • It was an example, the difference between giving cut the filename to process and giving cut a string which matches the filename to process. – EightBitTony Jun 23 '13 at 09:06
2

I'm not sure by what method you're passing those filenames to cut, but it seems that you're passing them as filenames rather than data to manipulate.

cut ... << 'EOF'
file1
file2
EOF
Chris Down
  • 125,559
  • 25
  • 270
  • 266