In a Bash script, you can take a whole line as an argument by using the special variable space “ , “ and you can set the default seperator to “ \n ” with IFS=$'\n' when you want do seperate by line.
Let suppose you have a file ‘zz’
wire [3:0] dcs_ctrl |
And you wnat to print this file like this
wire [3:0] dcs_ctrl0 wire [3:0] dcs_ctrl1 wire [3:0] dcs_ctrl2 wire [3:0] dcs_ctrl3 |
For this, you have to do the operation for the whole line manually (like print the whole line 4 times as following).
for i in `cat zz`; do for j in {0..3}; do echo "$i"; done; done |
However, using the default seperator in bash is space , and you can set the default seperator to \n with IFS=$'\n', you can separately do it using the below code
$ cat zz wire [3:0] dcs_ctrl $ IFS=$'\n'; for i in `cat zz`; do for j in {0..3}; do echo "$i"; done; done wire [3:0] dcs_ctrl wire [3:0] dcs_ctrl wire [3:0] dcs_ctrl wire [3:0] dcs_ctrl |
Answered by: >LF-DevJourney
Credit:> StackOverflow
Suggested blogs:
>How to do wild grouping of friends in Python?
>How to download an entire S3 bucket - Complete Guide
>How to get item details of Woo Commerce in custom email content?
>How to install Laravel using composer and configure?
>How to merge cells with HTML, CSS, and PHP?
>How to Migrate your apps to Android 13
>How to Read a csv file with php using cURL
>How to read frame from ffmpeg subprocess in Python?