I have a file such as the following:
1234
ABCD
EFGH
I'd like to convert it to the following:
2341
BCDA
FGHE
The actual file has 4,000 words, so I would like to do this in an efficient manner. I tried using the command cut -c 2-4,1 file.txt
, but it produces the same exact output as the input. I was thinking I could use 3 different commands:
cut -c 1 file.txt > temp1.txt
cut -c 2-4 file.txt > temp2.txt
// combine the two with paste or pr
… but I would prefer a single command because I need to run it several times with slight modifications so running one command is less error prone than running 3 commands each time.
Is there any way to combine the 2 cut statements into one? Something like:
cut -c 1 file.txt | pr (cut -c 2-4 file.txt)
Or is there a better way to do this?
Best Answer
Using
sed
: