V-Tech Posted June 26, 2013 Share Posted June 26, 2013 Hello guys... So let's say i do cat ifcfg-eth? > test.txt Now i have 3 different eth and i want that when the info goes into the file it will place space or some kind of a break between each eth info. Can i do this? Thanks Link to comment Share on other sites More sharing options...
+Mud W1ggle Subscriber² Posted June 26, 2013 Subscriber² Share Posted June 26, 2013 for i in ifcfg-eth?;do cat $i >> test.txt ; echo >> test.txt; done that should place a balnk line between each ifcfg entry in the test.txt file Link to comment Share on other sites More sharing options...
V-Tech Posted June 26, 2013 Author Share Posted June 26, 2013 Thank you, it works great :) Any chance there is a shorter way to do it? Link to comment Share on other sites More sharing options...
+Mud W1ggle Subscriber² Posted June 26, 2013 Subscriber² Share Posted June 26, 2013 not that I can think of. Is that not short enough by itself? Link to comment Share on other sites More sharing options...
V-Tech Posted June 26, 2013 Author Share Posted June 26, 2013 It is, just a bit harder to remember :D That's o.k, thanks a lot for the help..... (Y) Link to comment Share on other sites More sharing options...
Karl L. Posted June 26, 2013 Share Posted June 26, 2013 If this is something you do frequently on your machine, have you considered aliasing it? I have many aliases that allow me to do things faster, and I would absolutely create an alias for that command if I used it frequently. Add something like the following to your ~/.bash_aliases or ~/.bashrc: function catifcfg { if [ -n "$1" ]; then outfile="$1" else outfile='test.txt' fi for infile in ifcfg-eth?; do cat $infile >> $outfile echo >> $outfile done } Link to comment Share on other sites More sharing options...
V-Tech Posted June 27, 2013 Author Share Posted June 27, 2013 If this is something you do frequently on your machine, have you considered aliasing it? I have many aliases that allow me to do things faster, and I would absolutely create an alias for that command if I used it frequently. Add something like the following to your ~/.bash_aliases or ~/.bashrc: function catifcfg { if [ -n "$1" ]; then outfile="$1" else outfile='test.txt' fi for infile in ifcfg-eth?; do cat $infile >> $outfile echo >> $outfile done } Thank you, it's a good idea to do it this way.... (Y) Link to comment Share on other sites More sharing options...
Recommended Posts