Skip to content

Instantly share code, notes, and snippets.

@chrishuan9
Last active September 6, 2022 07:49
Show Gist options
  • Save chrishuan9/8389104 to your computer and use it in GitHub Desktop.
Save chrishuan9/8389104 to your computer and use it in GitHub Desktop.
playing with awk
chris@opteron:~$ ls -la | awk '{ print $1 $9 }'
total
drwx------.
drwxr-xr-x..
drwx------.aptitude
-rw-------.bash_history
-rw-r--r--.bash_logout
-rw-r--r--.bashrc
drwx------.config
drwxr-xr-x.flexget
-rw-r--r--.forward
lrwxrwxrwxfs
-rw-------.lesshst
drwx------Mail
-rw-r--r--.profile
drwx------.ssh
-rw-------.viminfo
-rw-r--r--.vimrc
-rw-------.Xauthority
chris@opteron:~$
with cut:
chris@opteron:~$ ls -la >> test.txt
chris@opteron:~$ cut -d ' ' --fields=1,9 test.txt
total
drwx------ 21:37
drwxr-xr-x Oct
drwx------ 7
-rw------- .bash_history
-rw-r--r-- 23
-rw-r--r-- 21:31
drwx------ 14:15
drwxr-xr-x 21:00
-rw-r--r-- Jan
lrwxrwxrwx 7
-rw------- Jan
drwx------ 14:12
-rw-r--r-- 23
drwx------ 20:21
-rw-r--r-- 0
-rw------- 7
-rw-r--r-- 27
-rw------- Jan
chris@opteron:~$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment