diff --git a/core/commands/unixfs/ls.go b/core/commands/unixfs/ls.go
index ed1f70a88ea5c4312c8ca63bf19de55e16267e2b..ed2c0b1339d61a99e872965a586babdef098d2b6 100644
--- a/core/commands/unixfs/ls.go
+++ b/core/commands/unixfs/ls.go
@@ -184,9 +184,11 @@ directories, the child size is the IPFS link size.
 				if i > 0 || len(nonDirectories) > 0 {
 					fmt.Fprintln(w)
 				}
-				for _, arg := range directories[i:] {
-					if output.Arguments[arg] == hash {
-						fmt.Fprintf(w, "%s:\n", arg)
+				if len(output.Arguments) > 1 {
+					for _, arg := range directories[i:] {
+						if output.Arguments[arg] == hash {
+							fmt.Fprintf(w, "%s:\n", arg)
+						}
 					}
 				}
 				for _, link := range object.Links {
diff --git a/test/sharness/t0200-unixfs-ls.sh b/test/sharness/t0200-unixfs-ls.sh
index 51ba0614bbe64593310ea514c66ffa807fac1d9b..a79c098a495dfb05461b21f9e77b84b97d71e352 100755
--- a/test/sharness/t0200-unixfs-ls.sh
+++ b/test/sharness/t0200-unixfs-ls.sh
@@ -38,12 +38,24 @@ test_ls_cmd() {
 		test_cmp expected_add actual_add
 	'
 
+	test_expect_success "'ipfs file ls <dir>' succeeds" '
+		ipfs file ls QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy >actual_ls_one_directory
+	'
+
+	test_expect_success "'ipfs file ls <dir>' output looks good" '
+		cat <<-\EOF >expected_ls_one_directory &&
+			1024
+			a
+		EOF
+		test_cmp expected_ls_one_directory actual_ls_one_directory
+	'
+
 	test_expect_success "'ipfs file ls <three dir hashes>' succeeds" '
-		ipfs file ls QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss >actual_ls
+		ipfs file ls QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss >actual_ls_three_directories
 	'
 
 	test_expect_success "'ipfs file ls <three dir hashes>' output looks good" '
-		cat <<-\EOF >expected_ls &&
+		cat <<-\EOF >expected_ls_three_directories &&
 			QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy:
 			1024
 			a
@@ -58,7 +70,7 @@ test_ls_cmd() {
 			f1
 			f2
 		EOF
-		test_cmp expected_ls actual_ls
+		test_cmp expected_ls_three_directories actual_ls_three_directories
 	'
 
 	test_expect_success "'ipfs file ls <file hashes>' succeeds" '