Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

awk for loop

cat file.txt | awk '{ for(i=1; i<=8 ; i++) print $i}'

file.txt :
AAA BBB CCC DDD

output : 
AAA
BBB
CCC
DDD
Comment

awk for loop

{ for (i=1;i<=8;i++) {print $i} }
# Examples 

# Print first 8 fields of each line of text file
awk '{ for (i=1;i<=8;i++) {printf $i" "} }' /path/to/text/file

# Print first 8 fields of each line of text file in reverse order
awk '{ for (i=8;i<=1;i--) {printf $i" "} }' /path/to/text/file

# Print all but the last two fields of each line of text file
awk '{ for (i=1;i<=(NF-2);i++) {printf $i" "} }' /path/to/text/file
Comment

PREVIOUS NEXT
Code Example
Shell :: How to undo a pushed merge 
Shell :: conda check cuda version 
Shell :: Clear heroku redis cache 
Shell :: how to turn on scroll lock in ubuntu 
Shell :: react router dom with typescript 
Shell :: specify ssh key to use 
Shell :: xclip does not work 
Shell :: dbeaver linux 
Shell :: sed replace in file 
Shell :: install crossover in linux 
Shell :: git log graph oneline 
Shell :: git command line see log 
Shell :: install emacs 
Shell :: bash how to trim every nth line 
Shell :: npm ERR! path /usr/local/lib/nodejs/node-v10.15.3-linux-x64/lib/node_modules while installing angular cli 
Shell :: delete mulitple git branch 
Shell :: windows kill process on port 
Shell :: redis-cli port host 
Shell :: Expose local postgres database over https 
Shell :: express generator 
Shell :: git bash set global username and password 
Shell :: ubuntu mouse cursor disappears 
Shell :: install zsh hyper mac 
Shell :: linux find text in files recursively -include 
Shell :: add root user kali linux 
Shell :: install python for latex with dependencies 
Shell :: ffmpeg mkv to mp4 
Shell :: scp connection refused 
Shell :: git pull from another user 
Shell :: git log show branch of commit 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =