0

The output looks like this

bbnum,building,floor,cluster,row,position,namespaces

BBEG,BUILDEG,1,CLUsEG,5,19,namespaceEG

I would like to add spaces throughout, match up the top row with the bottom and delete cluster, row and namespaces (Delete the top and bottom part of the provided list)

Im trying to make it look something like this. Just trying to make it look neat

bbnum  building  floor  row  position

BBEG   BUILDEG    1          5     19

Any help would be greatly appreciated!!

4
  • The output of what? You should be able to do what you want with printf, you can specify the width of each field in the format satring. Commented Apr 3, 2020 at 21:01
  • Almost but not quite. awk -F, -v OFS='\t' '{$NF = ""; $1=$1}1' file.txt Commented Apr 3, 2020 at 21:17
  • Or ... command_with_output | awk -F, -v OFS='\t' '{$NF = ""; $1=$1}1' Commented Apr 3, 2020 at 21:24
  • Or ...| awk '{print $1, $2, $3, $5, $6}' FS=, OFS=\\t Commented Apr 3, 2020 at 22:54

2 Answers 2

2

Edit: remove comma with sed and try piping your output to column -ts, command like this:

$ echo -e "bbnum,building,floor,cluster,row,position,namespaces\nBBEG,BUILDEG,1,CLUsEG,5,19,namespaceEG" | column -ts,
bbnum  building  floor  cluster  row  position  namespaces
BBEG   BUILDEG   1      CLUsEG   5    19        namespaceEG
Sign up to request clarification or add additional context in comments.

3 Comments

That worked perfectly! Thank you so much for your time.
@dreamchaser1024 Please have a look at <stackoverflow.com/help/someone-answers>
@Quasímodo: there you go
0
while read; do
  printf "%10s %10s %10s %10s\n" $(echo "$REPLY"|cut -d "," --output-delimiter " " -f 1-3,6)
done < yourfile.txt

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.