Delete all Windows partitions

beren43

New Member
Nov 25, 2019
13
0
1
Hi
I'm trying to delete all Windows partitions from disk
#!/bin/bash
check_windows_part=`fdisk -l | grep -i windows`
if [ -z "$check_windows_part"] then
fdisk /dev/sdb << EOF
d
w
EOF
fi
But syntax error near unexpected token `fi'
What's wrong ?
 

EffrafaxOfWug

Radioactive Member
Feb 12, 2015
1,395
501
113
Please use code tags when posting code.

The syntax error occurs because you're missing a semicolon between ']' and 'then'.

What is it you think this script snippet will achieve? Just grepping for "windows" in the output of fdisk isn't a guarantee of anything, and you're hard-coding the formatting of only /dev/sdb. If you're writing some sort of automation script you'll want a lot more sanity checks than this.
 
  • Like
Reactions: T_Minus