Replace spaces with commas from one file and send the output to another file.
tr -s '[:blank:]' ', ' < input.txt > output.txt |
It’s perfect for creating a comma delimited file for importing to Excel.
cloud engineer
Replace spaces with commas from one file and send the output to another file.
tr -s '[:blank:]' ', ' < input.txt > output.txt |
tr -s '[:blank:]' ', ' < input.txt > output.txt
It’s perfect for creating a comma delimited file for importing to Excel.
How to sort files in Bash.
Display contents
$ cat file.txt
bbb
aaa
ccc
kkk
uuu
ppp |
$ cat file.txt bbb aaa ccc kkk uuu ppp
Sort
$ sort file.txt
aaa
bbb
ccc
kkk
ppp
uuu |
$ sort file.txt aaa bbb ccc kkk ppp uuu
Sort in place
$ sort -o file.txt file.txt $ cat file.txt aaa bbb ccc kkk ppp uuu |
$ sort -o file.txt file.txt $ cat file.txt aaa bbb ccc kkk ppp uuu
Here’s how to restore or set the Bash prompt on RHEL systems.
echo "PS1='\u@\h \w]\$'" >> ~/.bashrc source ~/.bashrc |
echo "PS1='\u@\h \w]\$'" >> ~/.bashrc source ~/.bashrc
Here’s a bash script that creates a volume from a snapshot in AWS.
#!/bin/bash read -p "snapshotId : " snapshot read -p "server : " server read -p "tag1 : " tag1 read -p "tag2 : " tag2 read -p "region : " region read -p "zone : " zone read -p "profile : " profile aws ec2 create-volume \ --availability-zone $zone \ --encrypted \ --iops 3000 \ --volume-type gp3 \ --snapshot-id $snapshot \ --tag-specifications "ResourceType=volume,Tags=[{Key=Name,Value="$server"},{Key=tag1,Value="$tag1"},{Key=tag2,Value="$tag2"}]" \ --region $region \ --profile $profile |
#!/bin/bash read -p "snapshotId : " snapshot read -p "server : " server read -p "tag1 : " tag1 read -p "tag2 : " tag2 read -p "region : " region read -p "zone : " zone read -p "profile : " profile aws ec2 create-volume \ --availability-zone $zone \ --encrypted \ --iops 3000 \ --volume-type gp3 \ --snapshot-id $snapshot \ --tag-specifications "ResourceType=volume,Tags=[{Key=Name,Value="$server"},{Key=tag1,Value="$tag1"},{Key=tag2,Value="$tag2"}]" \ --region $region \ --profile $profile
Here’s a nice little command to open a browser from Bash.
#!/bin/bash open https://domain.com/path/to/web/page/index.html |
#!/bin/bash open https://domain.com/path/to/web/page/index.html
You can use this command to open a web page from your script.