1

If my input is something like below cat file

{ABC}
{ABC}
{ABC}
{ABC}
{ABC}

The output that I want

ABC
ABC
ABC
ABC
ABC

Is that got some ways to after generate the output and transfer the data into a existing file already ? Example another file name is FileOne Content is

123
123
123
123
123
ALphabet

Got any ways after use the awk command to generate the output that I wanted and transfer to the FileOne and paste after the Alphabet column?

I want something like this

123
123
123
123
123
Alphabet
ABC
ABC
ABC
ABC
ABC

Thanks if you can help me solve this.

1 Answer 1

0

Easier with sed:

sed -n 's/^{\(.*\)}$/\1/p' file >> FileOne

With awk:

awk '/^[{].*[}]$/ {print substr($0, 2, length - 2)}' file >> FileOne

>> opens the file in append mode on standard output, so the output of sed/awk will be appended to FileOne.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .