I need to get specific part of output from a bash script. I have a bash script which already shows the location of json file but I also need username of owner of json file.
I have tried cat userswithjson.txt | grep -o '/home/*'
but it didn't work.
files=$(find /home -name file.json -print)
echo "$files" >> userswithjson.txt
cat userswithjson | grep -o '/home/*'
Expected output: user
Actual output: /home/user/file.json
Content of userswithjson.txt
: /home/user/file.json