Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Shell Scripting
  • Kali Linux
  • Ubuntu
  • Red Hat
  • CentOS
  • Docker in Linux
  • Kubernetes in Linux
  • Linux interview question
  • Python
  • R
  • Java
  • C
  • C++
  • JavaScript
  • DSA
Open In App
Next Article:
Convert Text File Strings into Base64 encoding
Next article icon

Convert Text File Strings into Base64 encoding

Last Updated : 21 Apr, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

In the Linux system, you have a command base64. This helps you to convert text into base64 encoding but how can you change multiple lines of text into base64 encoding. We will understand some common Linux command in this article. That helps us to solve our problems. We will discuss piping, echo, and how to get user input from the keyboard.

Example:

 

Echo Command

In Linux System, you have an echo command that printing strings and numerical values in the terminal 

echo  "Your String"

Example:

 

Encoding and Decoding Text

Syntax base64:

base64 options filename

Convert Text into base64 encoding

echo Team | base64

Output

 

Decode base64 text into plain text

echo base64_text | base64 -d

Output:

 

Encoding Text File into base64 encoding

Use this Syntax:

base64 filename

Output:

Encoding Text file

Decoding base64 File into plain Text

base64 -d filename

Encoding any user Defined Text

First, we create a shell script for this task read input from users, and  convert text into base64 encoding

Use this Shell Script

#! bin/bash  echo Enter you Text  read data  output=`echo -n $data | base64`   echo "Encoding Data $output"

Piping

Piping is reading input from one command and serving to another command. Now let's Combine all of these commands and solve our problem. Suppose, we have a text file name of the file name.txt

Example:

$ cat names.txt  Ahmedabad  Taj Mahal  India Gate  Qutub Minar 

So we can change these strings to base64 encoding in following way:-

cat names.txt | while read names do;  echo $names | base64 ; done

Output:

 

Next Article
Convert Text File Strings into Base64 encoding

N

neeraj3304
Improve
Article Tags :
  • Linux-Unix
  • linux-command
  • Linux-text-processing-commands

Similar Reads

    CodExt – Encode/decode anything with Python
    Encoding and Decoding are important factors for secure communication. To save confidential data from attackers, we need to encode the information. So we can use the CodExt tool which is developed to encode and decode secret information for secure communication. CodExt tool is developed in the python
    2 min read
    iconv command in Linux with Examples
    The iconv command is used to convert some text in one encoding into another encoding. If no input file is provided then it reads from standard input. Similarly, if no output file is given then it writes to standard output. If no from-encoding or to-encoding is provided then it uses current local's c
    3 min read
    Working with Magic numbers in Linux
    This article aims at giving an introduction to magic numbers and file headers, how to extract a file based on magic numbers, and how to corrupt and repair a file based on magic numbers in the Linux environment. Magic Numbers Magic numbers are the first few bytes of a file that are unique to a partic
    7 min read
    Encoding and Decoding Base64 Strings in Python
    The Base64 encoding is used to convert bytes that have binary or text data into ASCII characters. Encoding prevents the data from getting corrupted when it is transferred or processed through a text-only system. In this article, we will discuss about Base64 encoding and decoding and its uses to enco
    4 min read
    Base64 Java Encode and Decode a String
    Base64 encoding allows encoding binary data as text strings for safe transport, at the cost of larger data size. It is commonly used when there is a need to encode binary data that needs to be stored or transferred via media that are designed to deal with textual data (like transporting images insid
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences