我试图提取年份并将其打印在单独的新列上,并保持新列对齐.
这是输入文件:
0000000124 462910 8.8 Star Wars: Episode V - The Empire Strikes Back (1980)
0000000124 698356 8.8 The Lord of the Rings: The Fellowship of the Ring (2001)
0000000233 393855 8.8 One Flew Over the Cuckoo's Nest (1975)
0000000124 733447 8.7 Inception (2010)
0000000233 411397 8.7 Goodfellas (1990)
0000000123 519051 8.7 Star Wars (1977)
0000000124 146841 8.7 Shichinin no samurai (1954)
0000000123 618195 8.7 Forrest Gump (1994)
0000000123 680520 8.7 The Matrix (1999)
0000000123 604519 8.7 The Lord of the Rings: The Two Towers (2002)
0000000233 309137 8.7 Cidade de Deus (2002)
0000000232 548307 8.6 Se7en (1995)
0000000232 459707 8.6 The Silence of the Lambs (1991)
Run Code Online (Sandbox Code Playgroud)
我怎样才能在这样一个单独的专栏中获得这些年份?
0000000124 462910 8.8 Star Wars: Episode V - The Empire Strikes Back 1980
0000000124 698356 8.8 The Lord of the Rings: The Fellowship of the Ring 2001
0000000233 393855 8.8 One Flew Over the Cuckoo's Nest 1975
0000000124 733447 8.7 Inception 2010
0000000233 411397 8.7 Goodfellas 1990
0000000123 519051 8.7 Star Wars 1977
0000000124 146841 8.7 Shichinin no samurai 1954
0000000123 618195 8.7 Forrest Gump 1994
0000000123 680520 8.7 The Matrix 1999
0000000123 604519 8.7 The Lord of the Rings: The Two Towers 2002
0000000233 309137 8.7 Cidade de Deus 2002
0000000232 548307 8.6 Se7en 1995
0000000232 459707 8.6 The Silence of the Lambs 1991
Run Code Online (Sandbox Code Playgroud)
sed 's/)\s*$//' file|column -s '(' -t
Run Code Online (Sandbox Code Playgroud)
将在给定的输入上工作并为您提供预期的输出.
在这里测试:
kent$ echo "0000000124 462910 8.8 Star Wars: Episode V - The Empire Strikes Back (1980)
0000000124 698356 8.8 The Lord of the Rings: The Fellowship of the Ring (2001)
0000000233 393855 8.8 One Flew Over the Cuckoo's Nest (1975)
0000000124 733447 8.7 Inception (2010)
0000000233 411397 8.7 Goodfellas (1990)
0000000123 519051 8.7 Star Wars (1977)
0000000124 146841 8.7 Shichinin no samurai (1954)
0000000123 618195 8.7 Forrest Gump (1994)
0000000123 680520 8.7 The Matrix (1999)
0000000123 604519 8.7 The Lord of the Rings: The Two Towers (2002)
0000000233 309137 8.7 Cidade de Deus (2002)
0000000232 548307 8.6 Se7en (1995)
0000000232 459707 8.6 The Silence of the Lambs (1991)"|sed 's/)\s*$//'|column -s '(' -t
0000000124 462910 8.8 Star Wars: Episode V - The Empire Strikes Back 1980
0000000124 698356 8.8 The Lord of the Rings: The Fellowship of the Ring 2001
0000000233 393855 8.8 One Flew Over the Cuckoo's Nest 1975
0000000124 733447 8.7 Inception 2010
0000000233 411397 8.7 Goodfellas 1990
0000000123 519051 8.7 Star Wars 1977
0000000124 146841 8.7 Shichinin no samurai 1954
0000000123 618195 8.7 Forrest Gump 1994
0000000123 680520 8.7 The Matrix 1999
0000000123 604519 8.7 The Lord of the Rings: The Two Towers 2002
0000000233 309137 8.7 Cidade de Deus 2002
0000000232 548307 8.6 Se7en 1995
0000000232 459707 8.6 The Silence of the Lambs 1991
Run Code Online (Sandbox Code Playgroud)