Can we do grep and sed from a file and push the output into a variable
grep "^/dev/disk/by-id/scsi-*" /tmp/disks.txt | sed '{'s/=.*//'}'
Output would be like this:
/dev/disk/by-id/scsi-3644a8420420897001f2af8cc054d33bb
/dev/disk/by-id/scsi-3644a8420420897001ef50fcb0f778b86-part3
/dev/disk/by-id/scsi-3644a8420420897001ef50fcb0f778b86-part2
Error:
[/~]# grep "^/dev/disk/by-id/scsi-*" /tmp/disks.txt | sed {'s/=.*//'} >> $x
-bash: $x: ambiguous redirect
Can we push all 3 lines into a variable and call them with foreach? Thanks!
[root@localhost ~]# x=$(grep "^/dev/disk/by-id/scsi-" /tmp/del.txt | sed {'s/=.//'})
[root@localhost ~]# $x -bash: /dev/disk/by-id/scsi-3644a8420420897001f2af8cc054d33bb: Permission denied
[root@localhost ~]# x=$(grep "^/dev/disk/by-id/scsi-*" /tmp/del.txt | sed {'s/=.*//'})
[root@localhost ~]# $x -bash: /dev/disk/by-id/scsi-3644a8420420897001f2af8cc054d33bb: Permission denied – Jacky May 24 '17 at 06:17