• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Search

find

GCP Find Instance Boot Disk

April 13, 2022

How to find a boot disk from an instance.

gcloud compute instances describe servername \
--format='get(disks[0].source)' \
--zone=us-central1-c \
--project project-id

gcloud compute instances describe servername \ --format='get(disks[0].source)' \ --zone=us-central1-c \ --project project-id

Result

https://www.googleapis.com/compute/v1/projects/project-id/zones/us-central1-f/disks/servername-boot

https://www.googleapis.com/compute/v1/projects/project-id/zones/us-central1-f/disks/servername-boot

Filed Under: Cloud Tagged With: boot, disk, find, gcp

Replace spaces with comma

February 4, 2020

Here’s a simple sed command to replace multiple spaces into a comma delimited file.

sample.txt

one       two
three     four

one two three four

The sed command.

sed 's/ \+ /,/g' sample.txt > sample2.txt

sed 's/ \+ /,/g' sample.txt > sample2.txt

sample2.txt

one,two
three,four

one,two three,four

Filed Under: Linux Tagged With: comma, find, replace, sed, spaces, tab

Count Number of Files in Directory

May 14, 2019

Get a count of the number of files in a directory.

# using ls
ls | wc -l
ls -Aq | wc -l
# include hidden files 
find . ! -name . -prune -print | grep -c /
find .//. ! -name . -print | grep -c //
# using tree if installed. yum install tree. apt-get install tree
tree

# using ls ls | wc -l ls -Aq | wc -l # include hidden files find . ! -name . -prune -print | grep -c / find .//. ! -name . -print | grep -c // # using tree if installed. yum install tree. apt-get install tree tree

Filed Under: Linux Tagged With: count, find, ls, tree, wc

  • Go to page 1
  • Go to page 2
  • Go to Next Page »
  • Home
  • About
  • Search

Copyright © 2023